@Override public String get(Property property) { return resolvedProps.get(property.getKey()); }
private ClientProperty(Property prop) { this(prop.getKey(), prop.getDefaultValue(), prop.getType(), prop.getDescription()); }
public static boolean isPropertyValid(String property, String value) { Property p = Property.getPropertyByKey(property); return (p == null || p.getType().isValidFormat(value)) && Property.isValidTablePropertyKey(property); }
private String isZooKeeperMutable(Property prop) { if (!Property.isValidZooPropertyKey(prop.getKey())) return "no"; if (Property.isFixedZooPropertyKey(prop)) return "yes but requires restart of the " + prop.getKey().split("[.]")[0]; return "yes"; }
private static void checkType(Property property, PropertyType type) { if (!property.getType().equals(type)) { String msg = "Configuration method intended for type " + type + " called with a " + property.getType() + " argument (" + property.getKey() + ")"; IllegalArgumentException err = new IllegalArgumentException(msg); log.error(msg, err); throw err; } }
try { final boolean isDefaultTokenType = conf.get(Property.TRACE_TOKEN_TYPE) .equals(Property.TRACE_TOKEN_TYPE.getDefaultValue()); String principal = conf.get(Property.TRACE_USER); if (conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) { .newInstance(); int prefixLength = Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey().length(); for (Entry<String,String> entry : loginMap.entrySet()) { props.put(entry.getKey().substring(prefixLength), entry.getValue()); Property.TABLE_FORMATTER_CLASS.getKey(), TraceFormatter.class.getName()); break; } catch (AccumuloException | TableExistsException | TableNotFoundException | IOException
if (!Property.isValidTablePropertyKey(property)) { Shell.log.warn("Invalid per-table property : " + property + ", still removing from zookeeper if it's there."); Shell.log.debug("Successfully deleted table configuration option."); } else if (namespace != null) { if (!Property.isValidTablePropertyKey(property)) { Shell.log.warn("Invalid per-table property : " + property + ", still removing from zookeeper if it's there."); Shell.log.debug("Successfully deleted namespace configuration option."); } else { if (!Property.isValidZooPropertyKey(property)) { Shell.log.warn("Invalid per-table property : " + property + ", still removing from zookeeper if it's there."); if (!Property.isValidTablePropertyKey(property)) { throw new BadArgumentException("Invalid per-table property.", fullCommand, fullCommand.indexOf(property)); if (property.equals(Property.TABLE_DEFAULT_SCANTIME_VISIBILITY.getKey())) { new ColumnVisibility(value); // validate that it is a valid expression Shell.log.debug("Successfully set table configuration option."); } else if (namespace != null) { if (!Property.isValidTablePropertyKey(property)) { throw new BadArgumentException("Invalid per-table property.", fullCommand, fullCommand.indexOf(property));
String key = entry.getKey(); String value = entry.getValue(); Property prop = Property.getPropertyByKey(entry.getKey()); if (prop == null && Property.isValidPropertyKey(key)) continue; // unknown valid property (i.e. has proper prefix) else if (prop == null) log.warn(PREFIX + "unrecognized property key (" + key + ")"); else if (prop.getType() == PropertyType.PREFIX) fatal(PREFIX + "incomplete property key (" + key + ")"); else if (!prop.getType().isValidFormat(value)) fatal(PREFIX + "improperly formatted value for key (" + key + ", type=" + prop.getType() + ") : " + value); if (key.equals(Property.INSTANCE_ZK_TIMEOUT.getKey())) { instanceZkTimeoutValue = value; if (key.equals(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE_INDEX.getKey()) || key.equals(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE.getKey())) { long bsize = ConfigurationTypeHelper.getFixedMemoryAsBytes(value); Preconditions.checkArgument(bsize > 0 && bsize < Integer.MAX_VALUE, key if (key.equals(Property.INSTANCE_CRYPTO_SERVICE.getKey())) { String cryptoStrategy = Objects.requireNonNull(value); verifyValidClassName(key, cryptoStrategy, CryptoService.class);
log.info("{} = {}", key, (Property.isSensitive(key) ? "<hidden>" : entry.getValue())); Property prop = Property.getPropertyByKey(key); if (prop != null && conf.isPropertySet(prop, false)) { if (prop.isDeprecated()) { Property replacedBy = prop.replacedBy(); if (replacedBy != null) { log.warn("{} is deprecated, use {} instead.", prop.getKey(), replacedBy.getKey()); } else { log.warn("{} is deprecated", prop.getKey());
private String _get(Property property) { String key = property.getKey(); String value = null; if (Property.isValidZooPropertyKey(key)) { value = getRaw(key); } if (value == null || !property.getType().isValidFormat(value)) { if (value != null) log.error("Using parent value for {} due to improperly formatted {}: {}", key, property.getType(), value); value = parent.get(property); } return value; }
public static boolean setSystemProperty(ServerContext context, String property, String value) throws KeeperException, InterruptedException { if (!Property.isValidZooPropertyKey(property)) { IllegalArgumentException iae = new IllegalArgumentException( "Zookeeper property is not mutable: " + property); log.debug("Attempted to set zookeeper property. It is not mutable", iae); throw iae; } // Find the property taking prefix into account Property foundProp = null; for (Property prop : Property.values()) { if (prop.getType() == PropertyType.PREFIX && property.startsWith(prop.getKey()) || prop.getKey().equals(property)) { foundProp = prop; break; } } if ((foundProp == null || (foundProp.getType() != PropertyType.PREFIX && !foundProp.getType().isValidFormat(value)))) { IllegalArgumentException iae = new IllegalArgumentException( "Ignoring property " + property + " it is either null or in an invalid format"); log.debug("Attempted to set zookeeper property. Value is either null or invalid", iae); throw iae; } // create the zk node for this property and set it's data to the specified value String zPath = context.getZooKeeperRoot() + Constants.ZCONFIG + "/" + property; return context.getZooReaderWriter().putPersistentData(zPath, value.getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); }
void property(Property prop) { boolean depr = prop.isDeprecated(); doc.print("| <a name=\"" + prop.getKey().replace(".", "_") + "\" class=\"prop\"></a> " + prop.getKey() + " | "); doc.print(prop.isExperimental() ? "**Experimental.** " : ""); doc.print( (depr ? "**Deprecated.** " : "") + strike(sanitize(prop.getDescription()), depr) + "<br>"); doc.print(strike("**type:** " + prop.getType().name(), depr) + ", "); doc.print(strike("**zk mutable:** " + isZooKeeperMutable(prop), depr) + ", "); String defaultValue = sanitize(prop.getRawDefaultValue()).trim(); if (defaultValue.length() == 0) { defaultValue = strike("**default value:** empty", depr); } else if (defaultValue.contains("\n")) { // deal with multi-line values, skip strikethrough of value defaultValue = strike("**default value:** ", depr) + "\n```\n" + defaultValue + "\n```\n"; } else { if (prop.getType() == PropertyType.CLASSNAME && defaultValue.startsWith("org.apache.accumulo")) { defaultValue = strike("**default value:** " + "{% jlink -f " + defaultValue + " %}", depr); } else { defaultValue = strike("**default value:** " + "`" + defaultValue + "`", depr); } } doc.println(defaultValue + " |"); }
@Override public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) { final Token cmd = new Token(getName()); final Token sub = new Token("-" + setOpt.getOpt()); for (Property p : Property.values()) { if (!(p.getKey().endsWith(".")) && !p.isExperimental()) { sub.addSubcommand(new Token(p.toString())); } } cmd.addSubcommand(sub); root.addSubcommand(cmd); }
void prefixSection(Property prefix) { boolean depr = prefix.isDeprecated(); doc.print("| <a name=\"" + prefix.getKey().replace(".", "_") + "prefix\" class=\"prop\"></a> **" + prefix.getKey() + "*** | "); doc.print(prefix.isExperimental() ? "**Experimental.** " : ""); doc.println( (depr ? "**Deprecated.** " : "") + strike(sanitize(prefix.getDescription()), depr) + " |"); }
private void updatePlugins(String property) { if (property.equals(Property.MASTER_TABLET_BALANCER.getKey())) { AccumuloConfiguration conf = master.getConfiguration(); TabletBalancer balancer = Property.createInstanceFromPropertyName(conf, Property.MASTER_TABLET_BALANCER, TabletBalancer.class, new DefaultLoadBalancer()); balancer.init(master.getContext()); master.tabletBalancer = balancer; log.info("tablet balancer changed to {}", master.tabletBalancer.getClass().getName()); } }
ConfigurationDocGen(PrintStream doc) { this.doc = doc; this.prefixes = new ArrayList<>(); this.sortedProps = new TreeMap<>(); for (Property prop : Property.values()) { if (prop.isExperimental()) continue; if (prop.getType() == PropertyType.PREFIX) this.prefixes.add(prop); else this.sortedProps.put(prop.getKey(), prop); } }
private static void exportConfig(ServerContext context, Table.ID tableID, ZipOutputStream zipOut, DataOutputStream dataOut) throws AccumuloException, AccumuloSecurityException, IOException { DefaultConfiguration defaultConfig = DefaultConfiguration.getInstance(); Map<String,String> siteConfig = context.instanceOperations().getSiteConfiguration(); Map<String,String> systemConfig = context.instanceOperations().getSystemConfiguration(); TableConfiguration tableConfig = context.getServerConfFactory().getTableConfiguration(tableID); OutputStreamWriter osw = new OutputStreamWriter(dataOut, UTF_8); // only put props that are different than defaults and higher level configurations zipOut.putNextEntry(new ZipEntry(Constants.EXPORT_TABLE_CONFIG_FILE)); for (Entry<String,String> prop : tableConfig) { if (prop.getKey().startsWith(Property.TABLE_PREFIX.getKey())) { Property key = Property.getPropertyByKey(prop.getKey()); if (key == null || !defaultConfig.get(key).equals(prop.getValue())) { if (!prop.getValue().equals(siteConfig.get(prop.getKey())) && !prop.getValue().equals(systemConfig.get(prop.getKey()))) { osw.append(prop.getKey() + "=" + prop.getValue() + "\n"); } } } } osw.flush(); } }
/** * Create warning message related to initial password, if appropriate. * * ACCUMULO-2907 Remove unnecessary security warning from console message unless its actually * appropriate. The warning message should only be displayed when the value of * <code>instance.security.authenticator</code> differs between the SiteConfiguration and the * DefaultConfiguration values. * * @return String containing warning portion of console message. */ private String getInitialPasswordWarning(SiteConfiguration siteConfig) { String optionalWarning; Property authenticatorProperty = Property.INSTANCE_SECURITY_AUTHENTICATOR; if (siteConfig.get(authenticatorProperty).equals(authenticatorProperty.getDefaultValue())) optionalWarning = ": "; else optionalWarning = " (this may not be applicable for your security setup): "; return optionalWarning; }
private static void enableTracing(String hostname, String service, String spanReceivers, String zookeepers, long timeout, String zkPath, Map<String,String> properties) { Configuration conf = new Configuration(false); conf.set(Property.TRACE_SPAN_RECEIVERS.toString(), spanReceivers); // remaining properties will be parsed through an HTraceConfiguration by SpanReceivers setProperty(conf, TRACER_ZK_HOST, zookeepers); setProperty(conf, TRACER_ZK_TIMEOUT, (int) timeout); setProperty(conf, TRACER_ZK_PATH, zkPath); for (Entry<String,String> property : properties.entrySet()) { setProperty(conf, property.getKey().substring(Property.TRACE_SPAN_RECEIVER_PREFIX.getKey().length()), property.getValue()); } if (hostname != null) { setProperty(conf, TRACE_HOST_PROPERTY, hostname); } if (service != null) { setProperty(conf, TRACE_SERVICE_PROPERTY, service); } org.apache.htrace.Trace.setProcessId(service); ShutdownHookManager.get().addShutdownHook(() -> { Trace.off(); closeReceivers(); }, 0); loadSpanReceivers(conf); }
/** * Verify the provided properties are valid table properties. */ private void checkTableProperties(Map<String,String> props) { props.keySet().forEach((key) -> { if (!key.startsWith(Property.TABLE_PREFIX.toString())) { throw new IllegalArgumentException("'" + key + "' is not a valid table property"); } }); } }