@Override public void log(Level level, String message) { deployLogger.log(level, message); }
void checkName(String hostname) { // Give a warning if the host does not exist try { Object address = java.net.InetAddress.getByName(hostname); } catch (UnknownHostException e) { deployLogger.log(Level.WARNING, "Unable to lookup IP address of host: " + hostname); } if (! hostname.contains(".")) { deployLogger.log(Level.WARNING, "Host named '" + hostname + "' may not receive any config " + "since it is not a canonical hostname"); } }
static int readPort(Element spec, boolean isHosted, DeployLogger deployLogger) { String portString = spec.getAttribute("port"); int port = Integer.parseInt(portString); if (port < 0) throw new IllegalArgumentException(String.format("Invalid port %d.", port)); int legalPortInHostedVespa = Container.BASEPORT; if (isHosted && port != legalPortInHostedVespa) { deployLogger.log(LogLevel.WARNING, String.format("Trying to set port to %d for http server with id %s. You cannot set port to anything else than %s", port, spec.getAttribute("id"), legalPortInHostedVespa)); } return port; } }
protected void warn(String searchName, String fieldName, String msg) { String fullMsg = formatError(searchName, fieldName, msg); deployLogger.log(Level.WARNING, fullMsg); }
private void validateWarn(Exception e, DeployLogger deployLogger) { String msg = "Unable to execute 'vespa-verify-ranksetup', validation of rank expressions will only take place when you start Vespa: " + Exceptions.toMessageString(e); deployLogger.log(LogLevel.WARNING, msg); }
/** * This rule consumes a body statement of a field element. * * @param field The field to modify. */ final public void body(SDField field) throws ParseException { jj_consume_token(BODY); deployLogger.log(Level.WARNING, field + ": 'header/body' is deprecated and has no effect."); }
/** * This rule consumes a header statement of a field element. * * @param field The field to modify. */ final public void header(SDField field) throws ParseException { jj_consume_token(HEADER); deployLogger.log(Level.WARNING, field + ": 'header/body' is deprecated and has no effect."); }
public void warning(SAXParseException e) { deployLogger.log(Level.WARNING, message(e)); }
private static String getJvmOptions(ContainerCluster cluster, Element nodesElement, DeployLogger deployLogger) { String jvmOptions = ""; if (nodesElement.hasAttribute(VespaDomBuilder.JVM_OPTIONS)) { jvmOptions = nodesElement.getAttribute(VespaDomBuilder.JVM_OPTIONS); if (nodesElement.hasAttribute(VespaDomBuilder.JVMARGS_ATTRIB_NAME)) { String jvmArgs = nodesElement.getAttribute(VespaDomBuilder.JVMARGS_ATTRIB_NAME); throw new IllegalArgumentException("You have specified both jvm-options='" + jvmOptions + "'" + " and deprecated jvmargs='" + jvmArgs + "'. Merge jvmargs into jvm-options."); } } else { jvmOptions = nodesElement.getAttribute(VespaDomBuilder.JVMARGS_ATTRIB_NAME); if (incompatibleGCOptions(jvmOptions)) { deployLogger.log(Level.WARNING, "You need to move out your GC related options from 'jvmargs' to 'jvm-gc-options'"); cluster.setJvmGCOptions(ContainerCluster.G1GC); } } return jvmOptions; } private void addNodesFromXml(ContainerCluster cluster, Element containerElement, ConfigModelContext context) {
public void validateOSGIHeaders(DeployLogger deployLogger) throws IOException { Manifest mf = jarFile.getManifest(); if (mf == null) { throw new IllegalArgumentException("Non-existing or invalid manifest in " + jarFile.getName()); } // Check for required OSGI headers Attributes attributes = mf.getMainAttributes(); HashSet<String> mfAttributes = new HashSet<>(); for (Object attributeSet : attributes.entrySet()) { Map.Entry<Object, Object> e = (Map.Entry<Object, Object>) attributeSet; mfAttributes.add(e.getKey().toString()); } List<String> requiredOSGIHeaders = Arrays.asList( "Bundle-ManifestVersion", "Bundle-Name", "Bundle-SymbolicName", "Bundle-Version"); for (String header : requiredOSGIHeaders) { if (!mfAttributes.contains(header)) { throw new IllegalArgumentException("Required OSGI header '" + header + "' was not found in manifest in '" + jarFile.getName() + "'"); } } if (attributes.getValue("Bundle-Version").endsWith(".SNAPSHOT")) { deployLogger.log(Level.WARNING, "Deploying snapshot bundle " + jarFile.getName() + ".\nTo use this bundle, you must include the qualifier 'SNAPSHOT' in the version specification in services.xml."); } } }
private Optional<ChangesRequiringRestart> compareConfigFromCurrentAndNextModel( Service service, Class<? extends ConfigInstance> configClass, AbstractConfigProducerRoot currentModel, AbstractConfigProducerRoot nextModel) { if (!hasConfigFieldsFlaggedWithRestart(configClass, service.getClass())) { logger.log(Level.FINE, String.format("%s is listed in the annotation for %s, " + "but does not have any restart flags in its config definition.", configClass.getSimpleName(), service.getClass().getSimpleName())); return Optional.empty(); } Optional<ConfigInstance> nextConfig = getConfigFromModel(nextModel, configClass, service.getConfigId()); if (!nextConfig.isPresent()) { logger.log(Level.FINE, String.format( "%s is listed as restart config for %s, but the config does not exist in the new model.", configClass.getSimpleName(), service.getClass().getSimpleName())); return Optional.empty(); } Optional<ConfigInstance> currentConfig = getConfigFromModel(currentModel, configClass, service.getConfigId()); if (!currentConfig.isPresent()) { return Optional.empty(); } return Optional.of(ReflectionUtil.getChangesRequiringRestart(currentConfig.get(), nextConfig.get())); }
private void checkCommand(String command) { for (SDField field : fields) { if (!field.hasQueryCommand(command)) { if (harmonizedCommands.contains(command)) { deployLogger.log(Level.WARNING, command + " must be added to all fields going to the same index (" + indexName + ")" + ", adding to field " + field.getName()); field.addQueryCommand(command); } else { deployLogger.log(Level.WARNING, "All fields going to the same index should have the same query-commands. Field \'" + field.getName() + "\' doesn't contain command \'" + command+"\'"); } } } } }
@Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; if (documentsOnly) return; for (RankProfile rp : rankProfileRegistry.all()) { for (String functionName : rp.getFunctions().keySet()) { if (reservedNames.contains(functionName)) { deployLogger.log(Level.WARNING, "Function '" + functionName + "' " + "in rank profile '" + rp.getName() + "' " + "has a reserved name. This might mean that the function shadows " + "the built-in function with the same name." ); } } } }
private void addField(String name, DataType type, SummaryTransform transform) { if (fields.containsKey(name)) { SummaryClassField sf = fields.get(name); if (!SummaryClassField.convertDataType(type, transform).equals(sf.getType())) { deployLogger.log(Level.WARNING, "Conflicting definition of field " + name + ". " + "Declared as type " + sf.getType() + " and " + type); } } else { fields.put(name, new SummaryClassField(name, type, transform)); } }
public StorageGroup buildRootGroup(DeployState deployState) { Optional<ModelElement> group = Optional.ofNullable(clusterElement.getChild("group")); Optional<ModelElement> nodes = getNodes(clusterElement); if (group.isPresent() && nodes.isPresent()) throw new IllegalStateException("Both group and nodes exists, only one of these tags is legal"); if (group.isPresent() && (group.get().getStringAttribute("name") != null || group.get().getIntegerAttribute("distribution-key") != null)) deployState.getDeployLogger().log(LogLevel.INFO, "'distribution-key' attribute on a content cluster's root group is ignored"); GroupBuilder groupBuilder = collectGroup(group, nodes, null, null); if (owner.isHostedVespa()) { return groupBuilder.buildHosted(deployState, owner, Optional.empty()); } else { return groupBuilder.buildNonHosted(deployState, owner, Optional.empty()); } }
private static void buildElement(Element element, Map<ConfigDefinitionKey, ConfigPayloadBuilder> builderMap, ConfigDefinitionStore configDefinitionStore, DeployLogger logger) { ConfigDefinitionKey key = DomConfigPayloadBuilder.parseConfigName(element); Optional<ConfigDefinition> def = configDefinitionStore.getConfigDefinition(key); if ( ! def.isPresent()) { // TODO: Fail instead of warn logger.log(LogLevel.WARNING, "Unable to find config definition '" + key.asFileName() + "'. Please ensure that the name is spelled correctly, and that the def file is included in a bundle."); } ConfigPayloadBuilder payloadBuilder = new DomConfigPayloadBuilder(def.orElse(null)).build(element); ConfigPayloadBuilder old = builderMap.get(key); if (old != null) { logger.log(LogLevel.WARNING, "Multiple overrides for " + key + " found. Applying in the order they are discovered"); old.override(payloadBuilder); } else { builderMap.put(key, payloadBuilder); } }
private void validateFail(String output, SearchCluster sc, String sdName, DeployLogger deployLogger) { String errMsg = "For search cluster '" + sc.getClusterName() + "', search definition '" + sdName + "': error in rank setup. Details:\n"; for (String line : output.split("\n")) { // Remove debug lines from start script if (line.startsWith("debug\t")) continue; try { LogMessage logmsg = LogMessage.parseNativeFormat(line); errMsg = errMsg + logmsg.getLevel() + ": " + logmsg.getPayload() + "\n"; } catch (InvalidLogFormatException e) { errMsg = errMsg + line + "\n"; } } if (force) { deployLogger.log(LogLevel.WARNING, errMsg + "(Continuing because of force.)"); } else { throw new IllegalArgumentException(errMsg); } }
private static void warnStreamingAttribute(SearchCluster sc, SDField sd, DeployLogger logger) { // If the field is numeric, we can't print this, because we may have converted the field to // attribute indexing ourselves (IntegerIndex2Attribute) if (sd.getDataType() instanceof NumericDataType) return; logger.log(Level.WARNING, "For streaming search cluster '" + sc.getClusterName() + "', SD field '" + sd.getName() + "': 'attribute' has same match semantics as 'index'."); }
/** * This rule consumes part of a rank-degradation statement of a rank profile. */ final public void rankDegradationBinLow() throws ParseException {int n; jj_consume_token(RPBINLOW); jj_consume_token(COLON); n = integer(); deployLogger.log(Level.WARNING, "Specifying 'min-fullrank-docs' in 'rank-degradation' is deprecated and has no effect."); }
private boolean canUseWantedPort(DeployLogger deployLogger, AbstractService service, int wantedPort, int serviceBasePort) { for (int i = 0; i < service.getPortCount(); i++) { int port = wantedPort + i; if (portDB.containsKey(port)) { AbstractService s = (AbstractService)portDB.get(port); deployLogger.log(Level.WARNING, service.getServiceName() +" cannot reserve port " + port + " on " + this + ": Already reserved for " + s.getServiceName() + ". Using default port range from " + serviceBasePort); return false; } if (!service.requiresConsecutivePorts()) break; } return true; }