protected Map<String,Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuTableConf) throws IOException { try { return LocalityGroupUtil.getLocalityGroups(acuTableConf); } catch (LocalityGroupConfigurationError e) { throw new IOException(e); } }
/** * Configures a table's locality groups prior to initial table creation. * * Allows locality groups to be set prior to table creation. Additional calls to this method prior * to table creation will overwrite previous locality group mappings. * * @param groups * mapping of locality group names to column families in the locality group * * @since 2.0.0 * * @see TableOperations#setLocalityGroups */ public NewTableConfiguration setLocalityGroups(Map<String,Set<Text>> groups) { // ensure locality groups do not overlap LocalityGroupUtil.ensureNonOverlappingGroups(groups); Map<String,String> tmp = new HashMap<>(); for (Entry<String,Set<Text>> entry : groups.entrySet()) { Set<Text> colFams = entry.getValue(); String value = LocalityGroupUtil.encodeColumnFamilies(colFams); tmp.put(Property.TABLE_LOCALITY_GROUP_PREFIX + entry.getKey(), value); } tmp.put(Property.TABLE_LOCALITY_GROUPS.getKey(), String.join(",", groups.keySet())); checkDisjoint(properties, tmp, "locality groups"); localityProps = tmp; return this; }
void checkLocalityGroups(String propChanged) throws AccumuloSecurityException, AccumuloException { if (LocalityGroupUtil.isLocalityGroupProperty(propChanged)) { try { LocalityGroupUtil.checkLocalityGroups(getSystemConfiguration().entrySet()); } catch (LocalityGroupConfigurationError | RuntimeException e) { LoggerFactory.getLogger(this.getClass()).warn("Changing '" + propChanged + "' resulted in bad locality group config. This may be a transient situation since " + "the config spreads over multiple properties. Setting properties in a different " + "order may help. Even though this warning was displayed, the property was updated. " + "Please check your config to ensure consistency.", e); } } }
iter.seek(range, LocalityGroupUtil.EMPTY_CF_SET, false); } else { iter.seek(range, LocalityGroupUtil.families(columns), true);
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { final String tableName = OptUtil.getTableOpt(cl, shellState); final Map<String,Set<Text>> groups = shellState.getAccumuloClient().tableOperations() .getLocalityGroups(tableName); for (Entry<String,Set<Text>> entry : groups.entrySet()) { shellState.getReader() .println(entry.getKey() + "=" + LocalityGroupUtil.encodeColumnFamilies(entry.getValue())); } return 0; }
public static String encodeColumnFamilies(Set<Text> colFams) { SortedSet<String> ecfs = new TreeSet<>(); StringBuilder sb = new StringBuilder(); for (Text text : colFams) { String ecf = encodeColumnFamily(sb, text.getBytes(), text.getLength()); ecfs.add(ecf); } return Joiner.on(",").join(ecfs); }
public static Set<ByteSequence> decodeColumnFamilies(String colFams) throws LocalityGroupConfigurationError { HashSet<ByteSequence> colFamsSet = new HashSet<>(); for (String family : colFams.split(",")) { ByteSequence cfbs = decodeColumnFamily(family); colFamsSet.add(cfbs); } return colFamsSet; }
@Override protected Map<String,Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuTableConf) throws IOException { return LocalityGroupUtil.getLocalityGroupsIgnoringErrors(acuTableConf, extent.getTableId()); }
if (result.containsKey(group)) { if (parts.length == 1) { Set<ByteSequence> colFamsSet = decodeColumnFamilies(value); if (!Collections.disjoint(all, colFamsSet)) { colFamsSet.retainAll(all);
/** * Sets additional properties to be applied to tables created with this configuration. Additional * calls to this method replace properties set by previous calls. * * @param props * additional properties to add to the table when it is created * @return this */ public NewTableConfiguration setProperties(Map<String,String> props) { checkArgument(props != null, "properties is null"); checkDisjoint(props, samplerProps, "sampler"); checkDisjoint(props, summarizerProps, "summarizer"); checkDisjoint(props, localityProps, "locality group"); checkDisjoint(props, iteratorProps, "iterator"); checkTableProperties(props); try { LocalityGroupUtil.checkLocalityGroups(props.entrySet()); } catch (LocalityGroupConfigurationError e) { throw new IllegalArgumentException(e); } this.properties = new HashMap<>(props); return this; }
cfset = LocalityGroupUtil.families(columnSet);
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { final String tableName = OptUtil.getTableOpt(cl, shellState); final Map<String,Set<Text>> groups = shellState.getConnector().tableOperations() .getLocalityGroups(tableName); for (Entry<String,Set<Text>> entry : groups.entrySet()) { shellState.getReader() .println(entry.getKey() + "=" + LocalityGroupUtil.encodeColumnFamilies(entry.getValue())); } return 0; }
public static String encodeColumnFamily(ByteSequence bs) { if (bs.offset() != 0) { throw new IllegalArgumentException("The offset cannot be non-zero."); } return encodeColumnFamily(new StringBuilder(), bs.getBackingArray(), bs.length()); }
public static Set<ByteSequence> decodeColumnFamilies(String colFams) throws LocalityGroupConfigurationError { HashSet<ByteSequence> colFamsSet = new HashSet<>(); for (String family : colFams.split(",")) { ByteSequence cfbs = decodeColumnFamily(family); colFamsSet.add(cfbs); } return colFamsSet; }
public InMemoryMap(AccumuloConfiguration config, ServerContext serverContext, Table.ID tableId) { boolean useNativeMap = config.getBoolean(Property.TSERV_NATIVEMAP_ENABLED); this.memDumpDir = config.get(Property.TSERV_MEMDUMP_DIR); this.lggroups = LocalityGroupUtil.getLocalityGroupsIgnoringErrors(config, tableId); this.config = config; this.context = serverContext; SimpleMap allMap; SimpleMap sampleMap; if (lggroups.size() == 0) { allMap = newMap(useNativeMap); sampleMap = newMap(useNativeMap); mapType = useNativeMap ? TYPE_NATIVE_MAP_WRAPPER : TYPE_DEFAULT_MAP; } else { allMap = new LocalityGroupMap(lggroups, useNativeMap); sampleMap = new LocalityGroupMap(lggroups, useNativeMap); mapType = useNativeMap ? TYPE_LOCALITY_GROUP_MAP_NATIVE : TYPE_LOCALITY_GROUP_MAP; } map = new SampleMap(allMap, sampleMap); }
if (result.containsKey(group)) { if (parts.length == 1) { Set<ByteSequence> colFamsSet = decodeColumnFamilies(value); if (!Collections.disjoint(all, colFamsSet)) { colFamsSet.retainAll(all);
families = LocalityGroupUtil.families(cols); iterator = IteratorUtil.setupSystemScanIterators(iterator, cols, getAuthorizations(), EMPTY_BYTES, tableConf);
public static Map<String,Set<ByteSequence>> getLocalityGroupsIgnoringErrors( AccumuloConfiguration acuconf, Table.ID tableId) { try { return getLocalityGroups(acuconf); } catch (LocalityGroupConfigurationError | RuntimeException e) { log.warn("Failed to get locality group config for tableId:" + tableId + ", proceeding without locality groups.", e); } return Collections.emptyMap(); }
throws AccumuloException, AccumuloSecurityException, TableNotFoundException { LocalityGroupUtil.ensureNonOverlappingGroups(groups); String value = LocalityGroupUtil.encodeColumnFamilies(colFams); setPropertyNoChecks(tableName, Property.TABLE_LOCALITY_GROUP_PREFIX + entry.getKey(), value);
String value = LocalityGroupUtil.encodeColumnFamilies(colFams); setProperty(tableName, Property.TABLE_LOCALITY_GROUP_PREFIX + entry.getKey(), value);