Search in sources :

Example 1 with TabletMutator

use of org.apache.accumulo.core.metadata.schema.Ample.TabletMutator in project accumulo by apache.

the class ZooTabletStateStore method unassign.

@Override
public void unassign(Collection<TabletLocationState> tablets, Map<TServerInstance, List<Path>> logsForDeadServers) throws DistributedStoreException {
    if (tablets.size() != 1)
        throw new IllegalArgumentException("There is only one root tablet");
    TabletLocationState tls = tablets.iterator().next();
    if (tls.extent.compareTo(RootTable.EXTENT) != 0)
        throw new IllegalArgumentException("You can only store the root tablet location");
    TabletMutator tabletMutator = ample.mutateTablet(tls.extent);
    tabletMutator.deleteLocation(tls.futureOrCurrent(), LocationType.FUTURE);
    tabletMutator.deleteLocation(tls.futureOrCurrent(), LocationType.CURRENT);
    if (logsForDeadServers != null) {
        List<Path> logs = logsForDeadServers.get(tls.futureOrCurrent());
        if (logs != null) {
            for (Path entry : logs) {
                LogEntry logEntry = new LogEntry(RootTable.EXTENT, System.currentTimeMillis(), entry.toString());
                tabletMutator.putWal(logEntry);
            }
        }
    }
    tabletMutator.mutate();
    log.debug("unassign root tablet location");
}
Also used : Path(org.apache.hadoop.fs.Path) TabletLocationState(org.apache.accumulo.core.metadata.TabletLocationState) TabletMutator(org.apache.accumulo.core.metadata.schema.Ample.TabletMutator) LogEntry(org.apache.accumulo.core.tabletserver.log.LogEntry)

Example 2 with TabletMutator

use of org.apache.accumulo.core.metadata.schema.Ample.TabletMutator in project accumulo by apache.

the class ZooTabletStateStore method setFutureLocations.

@Override
public void setFutureLocations(Collection<Assignment> assignments) throws DistributedStoreException {
    if (assignments.size() != 1)
        throw new IllegalArgumentException("There is only one root tablet");
    Assignment assignment = assignments.iterator().next();
    if (assignment.tablet.compareTo(RootTable.EXTENT) != 0)
        throw new IllegalArgumentException("You can only store the root tablet location");
    TabletMutator tabletMutator = ample.mutateTablet(assignment.tablet);
    tabletMutator.putLocation(assignment.server, LocationType.FUTURE);
    tabletMutator.mutate();
}
Also used : TabletMutator(org.apache.accumulo.core.metadata.schema.Ample.TabletMutator)

Example 3 with TabletMutator

use of org.apache.accumulo.core.metadata.schema.Ample.TabletMutator in project accumulo by apache.

the class ZooTabletStateStore method setLocations.

@Override
public void setLocations(Collection<Assignment> assignments) throws DistributedStoreException {
    if (assignments.size() != 1)
        throw new IllegalArgumentException("There is only one root tablet");
    Assignment assignment = assignments.iterator().next();
    if (assignment.tablet.compareTo(RootTable.EXTENT) != 0)
        throw new IllegalArgumentException("You can only store the root tablet location");
    TabletMutator tabletMutator = ample.mutateTablet(assignment.tablet);
    tabletMutator.putLocation(assignment.server, LocationType.CURRENT);
    tabletMutator.deleteLocation(assignment.server, LocationType.FUTURE);
    tabletMutator.mutate();
}
Also used : TabletMutator(org.apache.accumulo.core.metadata.schema.Ample.TabletMutator)

Example 4 with TabletMutator

use of org.apache.accumulo.core.metadata.schema.Ample.TabletMutator in project accumulo by apache.

the class ManagerMetadataUtil method addNewTablet.

public static void addNewTablet(ServerContext context, KeyExtent extent, String dirName, TServerInstance location, Map<StoredTabletFile, DataFileValue> datafileSizes, Map<Long, ? extends Collection<TabletFile>> bulkLoadedFiles, MetadataTime time, long lastFlushID, long lastCompactID, ServiceLock zooLock) {
    TabletMutator tablet = context.getAmple().mutateTablet(extent);
    tablet.putPrevEndRow(extent.prevEndRow());
    tablet.putZooLock(zooLock);
    tablet.putDirName(dirName);
    tablet.putTime(time);
    if (lastFlushID > 0)
        tablet.putFlushId(lastFlushID);
    if (lastCompactID > 0)
        tablet.putCompactionId(lastCompactID);
    if (location != null) {
        tablet.putLocation(location, LocationType.CURRENT);
        tablet.deleteLocation(location, LocationType.FUTURE);
    }
    datafileSizes.forEach(tablet::putFile);
    for (Entry<Long, ? extends Collection<TabletFile>> entry : bulkLoadedFiles.entrySet()) {
        for (TabletFile ref : entry.getValue()) {
            tablet.putBulkFile(ref, entry.getKey());
        }
    }
    tablet.mutate();
}
Also used : TabletMutator(org.apache.accumulo.core.metadata.schema.Ample.TabletMutator) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) TabletFile(org.apache.accumulo.core.metadata.TabletFile)

Example 5 with TabletMutator

use of org.apache.accumulo.core.metadata.schema.Ample.TabletMutator in project accumulo by apache.

the class MetadataTableUtil method updateTabletDir.

public static void updateTabletDir(KeyExtent extent, String newDir, ServerContext context, ServiceLock zooLock) {
    TabletMutator tablet = context.getAmple().mutateTablet(extent);
    tablet.putDirName(newDir);
    tablet.putZooLock(zooLock);
    tablet.mutate();
}
Also used : TabletMutator(org.apache.accumulo.core.metadata.schema.Ample.TabletMutator)

Aggregations

TabletMutator (org.apache.accumulo.core.metadata.schema.Ample.TabletMutator)18 StoredTabletFile (org.apache.accumulo.core.metadata.StoredTabletFile)4 TServerInstance (org.apache.accumulo.core.metadata.TServerInstance)4 TabletLocationState (org.apache.accumulo.core.metadata.TabletLocationState)3 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)2 TabletFile (org.apache.accumulo.core.metadata.TabletFile)2 DataFileValue (org.apache.accumulo.core.metadata.schema.DataFileValue)2 MetadataTime (org.apache.accumulo.core.metadata.schema.MetadataTime)2 LogEntry (org.apache.accumulo.core.tabletserver.log.LogEntry)2 Path (org.apache.hadoop.fs.Path)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)1 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)1 ClientContext (org.apache.accumulo.core.clientImpl.ClientContext)1 TableId (org.apache.accumulo.core.data.TableId)1