@Override public synchronized void start(StartContext startContext) throws StartException { super.start(startContext); if (pathRelativeTo != null) { callbackHandle = pathManager.getValue().registerCallback(pathRelativeTo, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED); } baseDir = new File(pathManager.getValue().resolveRelativePathEntry(path, pathRelativeTo)); if (!baseDir.exists()) { if (!baseDir.mkdirs()) { throw UndertowLogger.ROOT_LOGGER.failedToCreatePersistentSessionDir(baseDir); } } if (!baseDir.isDirectory()) { throw UndertowLogger.ROOT_LOGGER.invalidPersistentSessionDir(baseDir); } }
File tempDir = new File(pathManager.getPathEntry(TEMP_DIR).resolvePath(), deploymentName); tempDir.mkdirs(); warMetaData.setTempDir(tempDir);
final Resource resource = context.createResource(PathAddress.EMPTY_ADDRESS); populateModel(context, operation, resource); final ModelNode model = resource.getModel(); if (context.isNormalServer()) { final boolean bootTimeScan = context.isBooting() && (enabled == null || enabled == true); final String pathName = pathManager.resolveRelativePathEntry(path, relativeTo); File relativePath = null; if (relativeTo != null) { relativePath = new File(pathManager.getPathEntry(relativeTo).resolvePath());
@Override public void execute(final OperationContext context, final ModelNode operation) { final ModelNode model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS)); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); List<File> logFiles; try { logFiles = findFiles(logDir, model); } catch (IOException e) { logFiles = Collections.emptyList(); LoggingLogger.ROOT_LOGGER.errorProcessingLogDirectory(logDir); } final SimpleDateFormat dateFormat = new SimpleDateFormat(LogFileResourceDefinition.ISO_8601_FORMAT); final ModelNode result = context.getResult().setEmptyList(); for (File logFile : logFiles) { final ModelNode fileInfo = new ModelNode(); fileInfo.get(FILE_NAME.getName()).set(logFile.getName()); fileInfo.get(FILE_SIZE.getName()).set(logFile.length()); fileInfo.get(LAST_MODIFIED_DATE.getName()).set(dateFormat.format(new Date(logFile.lastModified()))); result.add(fileInfo); } context.completeStep(ResultHandler.NOOP_RESULT_HANDLER); } }
private String resolvePath() { return pathManagerValue.getValue().resolveRelativePathEntry(unresolvedPath, relativeTo); }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode model = context.getResult(); final String name = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, name); final Path path = Paths.get(logDir, name); if (Files.notExists(path)) { throw LoggingLogger.ROOT_LOGGER.logFileNotFound(name, logDir); } try { updateModel(path, model); } catch (IOException e) { throw new RuntimeException(e); } context.completeStep(ResultHandler.NOOP_RESULT_HANDLER); }
@Override public void started() { if (relativeToRef != null) { callbackHandle = pathManager.getValue().registerCallback(relativeToRef, PathManager.ReloadServerCallback.create(), PathManager.Event.REMOVED, PathManager.Event.UPDATED); } }
final PathManager pathManager = pathManagerValue.getValue(); final String pathName = pathManager.resolveRelativePathEntry(path, relativeTo); File relativePath = null; if (relativeTo != null) { relativePath = new File(pathManager.getPathEntry(relativeTo).resolvePath()); callbackHandle = pathManager.registerCallback(pathName, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED); relativePath, factory, scheduledExecutorValue.getValue());
final String cacheContainerName = address.getElement(CACHE_CONTAINER_INDEX).getValue(); final String metricName = operation.require(ModelDescriptionConstants.NAME).asString(); final ServiceController<?> controller = context.getServiceRegistry(false).getService(CacheContainerServiceName.CACHE_CONTAINER.getServiceName(cacheContainerName)); context.getFailureDescription().set(String.format("Unknown metric %s", metricName)); } else if (cacheManager == null) { context.getFailureDescription().set(String.format("Unavailable cache container %s", metricName)); } else { Health health = cacheManager.getHealth(); break; case LOG_TAIL: File path = new File(pathManager.resolveRelativePathEntry("server.log", ServerEnvironment.SERVER_LOG_DIR)); try (ReversedLinesFileReader reader = new ReversedLinesFileReader(path, StandardCharsets.UTF_8)) { List<String> results = new LinkedList<>();
private String resolve(final OperationContext context, final String relativeToPath, final String path) { // TODO it would be better if this came via the ExtensionContext ServiceName pathMgrSvc = context.getCapabilityServiceName("org.wildfly.management.path-manager", PathManager.class); @SuppressWarnings("unchecked") final ServiceController<PathManager> controller = (ServiceController<PathManager>) context.getServiceRegistry(false).getService(pathMgrSvc); if (controller == null) { return null; } return controller.getValue().resolveRelativePathEntry(path, relativeToPath); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, name); final Path path = Paths.get(logDir, name); try { String uuid = context.attachResultStream("text/plain", Files.newInputStream(path)); context.getResult().set(uuid); } catch (IOException e) { throw new RuntimeException(e); } } };
private static String resolvePath(OperationContext context, PathManager pathManager, PathElement pathElement) throws OperationFailedException { Resource serverResource = context.readResource(EMPTY_ADDRESS); // if the path resource does not exist, resolve its attributes against an empty ModelNode to get its default values final ModelNode model = serverResource.hasChild(pathElement) ? serverResource.getChild(pathElement).getModel() : new ModelNode(); final String path = PathDefinition.PATHS.get(pathElement.getValue()).resolveModelAttribute(context, model).asString(); final String relativeToPath = PathDefinition.RELATIVE_TO.resolveModelAttribute(context, model).asString(); final String relativeTo = AbsolutePathService.isAbsoluteUnixOrWindowsPath(path) ? null : relativeToPath; return pathManager.resolveRelativePathEntry(path, relativeTo); }
private String resolve(final OperationContext context, final String relativeToPath, final String path) { // TODO it would be better if this came via the ExtensionContext @SuppressWarnings("unchecked") final ServiceController<PathManager> controller = (ServiceController<PathManager>) context.getServiceRegistry(false).getService(PathManagerService.SERVICE_NAME); if (controller == null) { return null; } return controller.getValue().resolveRelativePathEntry(path, relativeToPath); } }
File resolve() { if (relativeTo != null) { File resolvedPath = new File(pathManager.resolveRelativePathEntry(path, relativeTo)); callbackHandle = pathManager.registerCallback(relativeTo, new org.jboss.as.controller.services.path.PathManager.Callback() { @Override public void pathModelEvent(PathEventContext eventContext, String name) { if (eventContext.isResourceServiceRestartAllowed() == false) { eventContext.reloadRequired(); } } @Override public void pathEvent(Event event, PathEntry pathEntry) { // Service dependencies should trigger a stop and start. } }, Event.REMOVED, Event.UPDATED); return resolvedPath; } else { return new File(path); } }
@Override public void start(StartContext startContext) { String relativeToPath = AbsolutePathService.isAbsoluteUnixOrWindowsPath(path) ? null : relativeTo; String dirPath = pathManager.get().resolveRelativePathEntry(path, relativeToPath); File dir = new File(dirPath); MicroProfileConfigLogger.ROOT_LOGGER.loadConfigSourceFromDir(dir.getAbsolutePath()); configSource = new DirConfigSource(dir, ordinal); }
synchronized void registerCallbacks(PathManager pathManager) { if (bindingsRelativeToPath != null) { callbackHandles.add(pathManager.registerCallback(bindingsRelativeToPath, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED)); } if (journalRelativeToPath != null) { callbackHandles.add(pathManager.registerCallback(journalRelativeToPath, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED)); } if (largeMessageRelativeToPath != null) { callbackHandles.add(pathManager.registerCallback(largeMessageRelativeToPath, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED)); } if (pagingRelativeToPath != null) { callbackHandles.add(pathManager.registerCallback(pagingRelativeToPath, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED)); } }
final Resource resource = context.createResource(PathAddress.EMPTY_ADDRESS); if (context.isNormalServer()) { final boolean bootTimeScan = context.isBooting() && enabled; final String pathName = pathManager.resolveRelativePathEntry(path, relativeTo); File relativePath = null; if (relativeTo != null) { relativePath = new File(pathManager.getPathEntry(relativeTo).resolvePath()); PathAddress ownerAddress = context.getCurrentAddress();
@Override public void execute(final OperationContext context, final ModelNode operation) { final ModelNode model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS)); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); List<File> logFiles; try { logFiles = findFiles(logDir, model); } catch (IOException e) { logFiles = Collections.emptyList(); LoggingLogger.ROOT_LOGGER.errorProcessingLogDirectory(logDir); } final SimpleDateFormat dateFormat = new SimpleDateFormat(LogFileResourceDefinition.ISO_8601_FORMAT); final ModelNode result = context.getResult().setEmptyList(); for (File logFile : logFiles) { final ModelNode fileInfo = new ModelNode(); fileInfo.get(FILE_NAME.getName()).set(logFile.getName()); fileInfo.get(FILE_SIZE.getName()).set(logFile.length()); fileInfo.get(LAST_MODIFIED_DATE.getName()).set(dateFormat.format(new Date(logFile.lastModified()))); result.add(fileInfo); } context.completeStep(ResultHandler.NOOP_RESULT_HANDLER); } }
private String resolvePath() { return pathManagerValue.getValue().resolveRelativePathEntry(unresolvedPath, relativeTo); }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode model = context.getResult(); final String name = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, name); final Path path = Paths.get(logDir, name); if (Files.notExists(path)) { throw LoggingLogger.ROOT_LOGGER.logFileNotFound(name, logDir); } try { updateModel(path, model); } catch (IOException e) { throw new RuntimeException(e); } context.completeStep(ResultHandler.NOOP_RESULT_HANDLER); }