Search in sources :

Example 6 with Assignment

use of org.apache.accumulo.server.master.state.Assignment in project accumulo by apache.

the class SplitRecoveryIT method splitPartiallyAndRecover.

private void splitPartiallyAndRecover(AccumuloServerContext context, KeyExtent extent, KeyExtent high, KeyExtent low, double splitRatio, SortedMap<FileRef, DataFileValue> mapFiles, Text midRow, String location, int steps, ZooLock zl) throws Exception {
    SortedMap<FileRef, DataFileValue> lowDatafileSizes = new TreeMap<>();
    SortedMap<FileRef, DataFileValue> highDatafileSizes = new TreeMap<>();
    List<FileRef> highDatafilesToRemove = new ArrayList<>();
    MetadataTableUtil.splitDatafiles(midRow, splitRatio, new HashMap<>(), mapFiles, lowDatafileSizes, highDatafileSizes, highDatafilesToRemove);
    MetadataTableUtil.splitTablet(high, extent.getPrevEndRow(), splitRatio, context, zl);
    TServerInstance instance = new TServerInstance(location, zl.getSessionId());
    Writer writer = MetadataTableUtil.getMetadataTable(context);
    Assignment assignment = new Assignment(high, instance);
    Mutation m = new Mutation(assignment.tablet.getMetadataEntry());
    assignment.server.putFutureLocation(m);
    writer.update(m);
    if (steps >= 1) {
        Map<Long, ? extends Collection<FileRef>> bulkFiles = MetadataTableUtil.getBulkFilesLoaded(context, extent);
        MasterMetadataUtil.addNewTablet(context, low, "/lowDir", instance, lowDatafileSizes, bulkFiles, TabletTime.LOGICAL_TIME_ID + "0", -1l, -1l, zl);
    }
    if (steps >= 2) {
        MetadataTableUtil.finishSplit(high, highDatafileSizes, highDatafilesToRemove, context, zl);
    }
    TabletServer.verifyTabletInformation(context, high, instance, new TreeMap<>(), "127.0.0.1:0", zl);
    if (steps >= 1) {
        ensureTabletHasNoUnexpectedMetadataEntries(context, low, lowDatafileSizes);
        ensureTabletHasNoUnexpectedMetadataEntries(context, high, highDatafileSizes);
        Map<Long, ? extends Collection<FileRef>> lowBulkFiles = MetadataTableUtil.getBulkFilesLoaded(context, low);
        Map<Long, ? extends Collection<FileRef>> highBulkFiles = MetadataTableUtil.getBulkFilesLoaded(context, high);
        if (!lowBulkFiles.equals(highBulkFiles)) {
            throw new Exception(" " + lowBulkFiles + " != " + highBulkFiles + " " + low + " " + high);
        }
        if (lowBulkFiles.size() == 0) {
            throw new Exception(" no bulk files " + low);
        }
    } else {
        ensureTabletHasNoUnexpectedMetadataEntries(context, extent, mapFiles);
    }
}
Also used : DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) Assignment(org.apache.accumulo.server.master.state.Assignment) FileRef(org.apache.accumulo.server.fs.FileRef) Mutation(org.apache.accumulo.core.data.Mutation) ZooReaderWriter(org.apache.accumulo.server.zookeeper.ZooReaderWriter) Writer(org.apache.accumulo.core.client.impl.Writer) IZooReaderWriter(org.apache.accumulo.fate.zookeeper.IZooReaderWriter)

Aggregations

Assignment (org.apache.accumulo.server.master.state.Assignment)6 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)5 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)5 TabletLocationState (org.apache.accumulo.server.master.state.TabletLocationState)4 ArrayList (java.util.ArrayList)3 Table (org.apache.accumulo.core.client.impl.Table)3 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 Mutation (org.apache.accumulo.core.data.Mutation)2 Range (org.apache.accumulo.core.data.Range)2 MetadataTable (org.apache.accumulo.core.metadata.MetadataTable)2 MergeStats (org.apache.accumulo.master.state.MergeStats)2 AccumuloServerContext (org.apache.accumulo.server.AccumuloServerContext)2 TServerConnection (org.apache.accumulo.server.master.LiveTServerSet.TServerConnection)2 MergeInfo (org.apache.accumulo.server.master.state.MergeInfo)2 MetaDataStateStore (org.apache.accumulo.server.master.state.MetaDataStateStore)2 BadLocationStateException (org.apache.accumulo.server.master.state.TabletLocationState.BadLocationStateException)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 List (java.util.List)1