use of org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError in project accumulo by apache.
the class Compactor method call.
@Override
public CompactionStats call() throws IOException, CompactionCanceledException {
FileSKVWriter mfw = null;
CompactionStats majCStats = new CompactionStats();
boolean remove = runningCompactions.add(this);
clearStats();
final Path outputFilePath = outputFile.path();
final String outputFilePathName = outputFilePath.toString();
String oldThreadName = Thread.currentThread().getName();
String newThreadName = "MajC compacting " + extent.toString() + " started " + dateFormatter.format(new Date()) + " file: " + outputFile;
Thread.currentThread().setName(newThreadName);
thread = Thread.currentThread();
try {
FileOperations fileFactory = FileOperations.getInstance();
FileSystem ns = this.fs.getVolumeByPath(outputFilePath).getFileSystem();
mfw = fileFactory.newWriterBuilder().forFile(outputFilePathName, ns, ns.getConf()).withTableConfiguration(acuTableConf).withRateLimiter(env.getWriteLimiter()).build();
Map<String, Set<ByteSequence>> lGroups;
try {
lGroups = LocalityGroupUtil.getLocalityGroups(acuTableConf);
} catch (LocalityGroupConfigurationError e) {
throw new IOException(e);
}
long t1 = System.currentTimeMillis();
HashSet<ByteSequence> allColumnFamilies = new HashSet<>();
if (mfw.supportsLocalityGroups()) {
for (Entry<String, Set<ByteSequence>> entry : lGroups.entrySet()) {
setLocalityGroup(entry.getKey());
compactLocalityGroup(entry.getKey(), entry.getValue(), true, mfw, majCStats);
allColumnFamilies.addAll(entry.getValue());
}
}
setLocalityGroup("");
compactLocalityGroup(null, allColumnFamilies, false, mfw, majCStats);
long t2 = System.currentTimeMillis();
FileSKVWriter mfwTmp = mfw;
// set this to null so we do not try to close it again in finally if the close fails
mfw = null;
try {
// if the close fails it will cause the compaction to fail
mfwTmp.close();
} catch (IOException ex) {
if (!fs.deleteRecursively(outputFile.path())) {
if (fs.exists(outputFile.path())) {
log.error("Unable to delete {}", outputFile);
}
}
throw ex;
}
log.debug(String.format("Compaction %s %,d read | %,d written | %,6d entries/sec | %,6.3f secs | %,12d bytes | %9.3f byte/sec", extent, majCStats.getEntriesRead(), majCStats.getEntriesWritten(), (int) (majCStats.getEntriesRead() / ((t2 - t1) / 1000.0)), (t2 - t1) / 1000.0, mfwTmp.getLength(), mfwTmp.getLength() / ((t2 - t1) / 1000.0)));
majCStats.setFileSize(mfwTmp.getLength());
return majCStats;
} catch (IOException | RuntimeException e) {
log.error("{}", e.getMessage(), e);
throw e;
} finally {
Thread.currentThread().setName(oldThreadName);
if (remove) {
thread = null;
runningCompactions.remove(this);
}
try {
if (mfw != null) {
// compaction must not have finished successfully, so close its output file
try {
mfw.close();
} finally {
if (!fs.deleteRecursively(outputFile.path()))
if (fs.exists(outputFile.path()))
log.error("Unable to delete {}", outputFile);
}
}
} catch (IOException | RuntimeException e) {
log.warn("{}", e.getMessage(), e);
}
}
}
use of org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError in project accumulo by apache.
the class LocalityGroupUtilTest method testColumnFamilySet.
@Test
public void testColumnFamilySet() {
ConfigurationCopy conf = new ConfigurationCopy();
conf.set("table.group.lg1", "cf1,cf2");
conf.set("table.groups.enabled", "lg1");
try {
Map<String, Set<ByteSequence>> groups = LocalityGroupUtil.getLocalityGroups(conf);
assertEquals(1, groups.size());
assertNotNull(groups.get("lg1"));
assertEquals(2, groups.get("lg1").size());
assertTrue(groups.get("lg1").contains(new ArrayByteSequence("cf1")));
} catch (LocalityGroupConfigurationError err) {
fail();
}
try {
conf.set("table.group.lg2", "cf1");
conf.set("table.groups.enabled", "lg1,lg2");
LocalityGroupUtil.getLocalityGroups(conf);
fail();
} catch (LocalityGroupConfigurationError err) {
// expected, ignore
}
}
use of org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError in project accumulo by apache.
the class TabletMemory method prepareForMinC.
public CommitSession prepareForMinC() {
if (otherMemTable != null) {
throw new IllegalStateException();
}
if (deletingMemTable != null) {
throw new IllegalStateException();
}
if (commitSession == null) {
throw new IllegalStateException();
}
otherMemTable = memTable;
try {
memTable = new InMemoryMap(tablet.getTableConfiguration());
} catch (LocalityGroupConfigurationError e) {
throw new RuntimeException(e);
}
CommitSession oldCommitSession = commitSession;
commitSession = new CommitSession(tablet, nextSeq, memTable);
nextSeq += 2;
tablet.updateMemoryUsageStats(memTable.estimatedSizeInBytes(), otherMemTable.estimatedSizeInBytes());
return oldCommitSession;
}
use of org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError in project accumulo by apache.
the class InMemoryMapMemoryUsageTest method init.
@Override
void init() {
try {
imm = new InMemoryMap(DefaultConfiguration.getInstance());
} catch (LocalityGroupConfigurationError e) {
throw new RuntimeException(e);
}
key = new Text();
colf = new Text(String.format("%0" + colFamLen + "d", 0));
colq = new Text(String.format("%0" + colQualLen + "d", 0));
colv = new ColumnVisibility(String.format("%0" + colVisLen + "d", 0));
}
Aggregations