Search in sources :

Example 1 with InMemoryMap

use of org.apache.accumulo.tserver.InMemoryMap in project accumulo by apache.

the class InMemoryMapIT method assertEquivalentMutate.

private void assertEquivalentMutate(List<Mutation> mutations) {
    InMemoryMap defaultMap = null;
    InMemoryMap nativeMapWrapper = null;
    InMemoryMap localityGroupMap = null;
    InMemoryMap localityGroupMapWithNative = null;
    try {
        Map<String, String> defaultMapConfig = new HashMap<>();
        defaultMapConfig.put(Property.TSERV_NATIVEMAP_ENABLED.getKey(), "false");
        defaultMapConfig.put(Property.TSERV_MEMDUMP_DIR.getKey(), tempFolder.newFolder().getAbsolutePath());
        defaultMapConfig.put(Property.TABLE_LOCALITY_GROUPS.getKey(), "");
        Map<String, String> nativeMapConfig = new HashMap<>();
        nativeMapConfig.put(Property.TSERV_NATIVEMAP_ENABLED.getKey(), "true");
        nativeMapConfig.put(Property.TSERV_MEMDUMP_DIR.getKey(), tempFolder.newFolder().getAbsolutePath());
        nativeMapConfig.put(Property.TABLE_LOCALITY_GROUPS.getKey(), "");
        Map<String, String> localityGroupConfig = new HashMap<>();
        localityGroupConfig.put(Property.TSERV_NATIVEMAP_ENABLED.getKey(), "false");
        localityGroupConfig.put(Property.TSERV_MEMDUMP_DIR.getKey(), tempFolder.newFolder().getAbsolutePath());
        Map<String, String> localityGroupNativeConfig = new HashMap<>();
        localityGroupNativeConfig.put(Property.TSERV_NATIVEMAP_ENABLED.getKey(), "true");
        localityGroupNativeConfig.put(Property.TSERV_MEMDUMP_DIR.getKey(), tempFolder.newFolder().getAbsolutePath());
        defaultMap = new InMemoryMap(new ConfigurationCopy(defaultMapConfig));
        nativeMapWrapper = new InMemoryMap(new ConfigurationCopy(nativeMapConfig));
        localityGroupMap = new InMemoryMap(updateConfigurationForLocalityGroups(new ConfigurationCopy(localityGroupConfig)));
        localityGroupMapWithNative = new InMemoryMap(updateConfigurationForLocalityGroups(new ConfigurationCopy(localityGroupNativeConfig)));
    } catch (Exception e) {
        log.error("Error getting new InMemoryMap ", e);
        fail(e.getMessage());
    }
    // ensure the maps are correct type
    assertEquals("Not a DefaultMap", InMemoryMap.TYPE_DEFAULT_MAP, defaultMap.getMapType());
    assertEquals("Not a NativeMapWrapper", InMemoryMap.TYPE_NATIVE_MAP_WRAPPER, nativeMapWrapper.getMapType());
    assertEquals("Not a LocalityGroupMap", InMemoryMap.TYPE_LOCALITY_GROUP_MAP, localityGroupMap.getMapType());
    assertEquals("Not a LocalityGroupMap with native", InMemoryMap.TYPE_LOCALITY_GROUP_MAP_NATIVE, localityGroupMapWithNative.getMapType());
    defaultMap.mutate(mutations);
    nativeMapWrapper.mutate(mutations);
    localityGroupMap.mutate(mutations);
    localityGroupMapWithNative.mutate(mutations);
    // let's use the transitive property to assert all four are equivalent
    assertMutatesEquivalent(mutations, defaultMap, nativeMapWrapper);
    assertMutatesEquivalent(mutations, defaultMap, localityGroupMap);
    assertMutatesEquivalent(mutations, defaultMap, localityGroupMapWithNative);
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) HashMap(java.util.HashMap) InMemoryMap(org.apache.accumulo.tserver.InMemoryMap) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with InMemoryMap

use of org.apache.accumulo.tserver.InMemoryMap 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 3 with InMemoryMap

use of org.apache.accumulo.tserver.InMemoryMap 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

InMemoryMap (org.apache.accumulo.tserver.InMemoryMap)3 LocalityGroupConfigurationError (org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)1 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)1 Text (org.apache.hadoop.io.Text)1