Search in sources :

Example 1 with LocalityGroupConfigurationError

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);
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) LocalityGroupConfigurationError(org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError) Set(java.util.Set) HashSet(java.util.HashSet) FileSKVWriter(org.apache.accumulo.core.file.FileSKVWriter) FileOperations(org.apache.accumulo.core.file.FileOperations) IOException(java.io.IOException) Date(java.util.Date) FileSystem(org.apache.hadoop.fs.FileSystem) ByteSequence(org.apache.accumulo.core.data.ByteSequence) HashSet(java.util.HashSet)

Example 2 with LocalityGroupConfigurationError

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
    }
}
Also used : LocalityGroupConfigurationError(org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError) ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) Set(java.util.Set) HashSet(java.util.HashSet) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) Test(org.junit.Test)

Example 3 with LocalityGroupConfigurationError

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;
}
Also used : LocalityGroupConfigurationError(org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError) InMemoryMap(org.apache.accumulo.tserver.InMemoryMap)

Example 4 with LocalityGroupConfigurationError

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));
}
Also used : LocalityGroupConfigurationError(org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError) InMemoryMap(org.apache.accumulo.tserver.InMemoryMap) Text(org.apache.hadoop.io.Text) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility)

Aggregations

LocalityGroupConfigurationError (org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError)4 HashSet (java.util.HashSet)2 Set (java.util.Set)2 InMemoryMap (org.apache.accumulo.tserver.InMemoryMap)2 IOException (java.io.IOException)1 Date (java.util.Date)1 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)1 ArrayByteSequence (org.apache.accumulo.core.data.ArrayByteSequence)1 ByteSequence (org.apache.accumulo.core.data.ByteSequence)1 FileOperations (org.apache.accumulo.core.file.FileOperations)1 FileSKVWriter (org.apache.accumulo.core.file.FileSKVWriter)1 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 Text (org.apache.hadoop.io.Text)1 Test (org.junit.Test)1