void updateTabletServer(String name, long sampleTime, long numEvents) { Pair<Long,Long> newSample = new Pair<>(sampleTime, numEvents); Pair<Long,Long> lastSample = samples.get(name); if (lastSample == null || !lastSample.equals(newSample)) { samples.put(name, newSample); if (lastSample != null) { prevSamples.put(name, lastSample); } } serversUpdated.add(name); }
public static String qualified(String tableName, String defaultNamespace) { Pair<String,String> qualifiedTableName = qualify(tableName, defaultNamespace); if (Namespace.DEFAULT.equals(qualifiedTableName.getFirst())) return qualifiedTableName.getSecond(); else return qualifiedTableName.toString("", ".", ""); }
public static Pair<String,String> qualify(String tableName, String defaultNamespace) { if (!tableName.matches(VALID_NAME_REGEX)) throw new IllegalArgumentException("Invalid table name '" + tableName + "'"); if (MetadataTable.OLD_NAME.equals(tableName)) tableName = MetadataTable.NAME; if (tableName.contains(".")) { String[] s = tableName.split("\\.", 2); return new Pair<>(s[0], s[1]); } return new Pair<>(defaultNamespace, tableName); }
double calculateRate() { double totalRate = 0; for (Entry<String,Pair<Long,Long>> entry : prevSamples.entrySet()) { Pair<Long,Long> prevSample = entry.getValue(); Pair<Long,Long> sample = samples.get(entry.getKey()); totalRate += (sample.getSecond() - prevSample.getSecond()) / ((sample.getFirst() - prevSample.getFirst()) / (double) 1000); } return totalRate; }
public static <K2,V2,K1 extends K2,V1 extends V2> Pair<K2,V2> fromEntry(Entry<K1,V1> entry) { return new Pair<>(entry.getKey(), entry.getValue()); }
@Override public boolean test(String tableName) { return !Namespace.ACCUMULO.equals(qualify(tableName).getFirst()); }
@Override public Value getTopValue() { return hasTop() ? keys.get(keyPos).getSecond() : null; }
private long removeFiles(Collection<Pair<WalState,Path>> collection, final GCStatus status) { for (Pair<WalState,Path> stateFile : collection) { Path path = stateFile.getSecond(); log.debug("Removing {} WAL {}", stateFile.getFirst(), path); status.currentLog.deleted += removeFile(path); } return status.currentLog.deleted; }
private Set<FileRef> removeSmallest(Map<FileRef,DataFileValue> filesToCompact, int maxFilesToCompact) { // ensure this method works properly when multiple files have the same size // short-circuit; also handles zero files case if (filesToCompact.size() <= maxFilesToCompact) { Set<FileRef> smallestFiles = new HashSet<>(filesToCompact.keySet()); filesToCompact.clear(); return smallestFiles; } PriorityQueue<Pair<FileRef,Long>> fileHeap = new PriorityQueue<>(filesToCompact.size(), (o1, o2) -> { if (o1.getSecond() == o2.getSecond()) return o1.getFirst().compareTo(o2.getFirst()); if (o1.getSecond() < o2.getSecond()) return -1; return 1; }); for (Iterator<Entry<FileRef,DataFileValue>> iterator = filesToCompact.entrySet() .iterator(); iterator.hasNext();) { Entry<FileRef,DataFileValue> entry = iterator.next(); fileHeap.add(new Pair<>(entry.getKey(), entry.getValue().getSize())); } Set<FileRef> smallestFiles = new HashSet<>(); while (smallestFiles.size() < maxFilesToCompact && fileHeap.size() > 0) { Pair<FileRef,Long> pair = fileHeap.remove(); filesToCompact.remove(pair.getFirst()); smallestFiles.add(pair.getFirst()); } return smallestFiles; }
private static Pair<SamplerConfigurationImpl,Sampler> getSampler(AccumuloConfiguration config) { try { SamplerConfigurationImpl sampleConfig = SamplerConfigurationImpl.newSamplerConfig(config); if (sampleConfig == null) { return new Pair<>(null, null); } return new Pair<>(sampleConfig, SamplerFactory.newSampler(sampleConfig, config)); } catch (IOException e) { throw new RuntimeException(e); } }
void updateTabletServer(String name, long sampleTime, long numEvents) { Pair<Long,Long> newSample = new Pair<>(sampleTime, numEvents); Pair<Long,Long> lastSample = samples.get(name); if (lastSample == null || !lastSample.equals(newSample)) { samples.put(name, newSample); if (lastSample != null) { prevSamples.put(name, lastSample); } } serversUpdated.add(name); }
private Sampler getOrCreateSampler() { Pair<SamplerConfigurationImpl,Sampler> pair = samplerRef.get(); if (pair == null) { pair = getSampler(config); if (!samplerRef.compareAndSet(null, pair)) { pair = samplerRef.get(); } } return pair.getSecond(); }