accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [15/54] [partial] ACCUMULO-658, ACCUMULO-656 Split server into separate modules
Date Fri, 01 Nov 2013 00:55:54 GMT
http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/MergeInfo.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/MergeInfo.java b/server/src/main/java/org/apache/accumulo/server/master/state/MergeInfo.java
deleted file mode 100644
index 708b1b7..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/MergeInfo.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.accumulo.core.data.KeyExtent;
-import org.apache.hadoop.io.Writable;
-
-/**
- * Information about the current merge/rangeDelete.
- * 
- * Writable to serialize for zookeeper and the Tablet
- */
-public class MergeInfo implements Writable {
-  
-  public enum Operation {
-    MERGE, DELETE,
-  }
-  
-  MergeState state = MergeState.NONE;
-  KeyExtent extent;
-  Operation operation = Operation.MERGE;
-  
-  public MergeInfo() {}
-  
-  @Override
-  public void readFields(DataInput in) throws IOException {
-    extent = new KeyExtent();
-    extent.readFields(in);
-    state = MergeState.values()[in.readInt()];
-    operation = Operation.values()[in.readInt()];
-  }
-  
-  @Override
-  public void write(DataOutput out) throws IOException {
-    extent.write(out);
-    out.writeInt(state.ordinal());
-    out.writeInt(operation.ordinal());
-  }
-  
-  public MergeInfo(KeyExtent range, Operation op) {
-    this.extent = range;
-    this.operation = op;
-  }
-  
-  public MergeState getState() {
-    return state;
-  }
-  
-  public KeyExtent getExtent() {
-    return extent;
-  }
-  
-  public Operation getOperation() {
-    return operation;
-  }
-  
-  public void setState(MergeState state) {
-    this.state = state;
-  }
-  
-  public boolean isDelete() {
-    return this.operation.equals(Operation.DELETE);
-  }
-  
-  public boolean needsToBeChopped(KeyExtent otherExtent) {
-    // During a delete, the block after the merge will be stretched to cover the deleted area.
-    // Therefore, it needs to be chopped
-    if (!otherExtent.getTableId().equals(extent.getTableId()))
-      return false;
-    if (isDelete())
-      return otherExtent.getPrevEndRow() != null && otherExtent.getPrevEndRow().equals(extent.getEndRow());
-    else
-      return this.extent.overlaps(otherExtent);
-  }
-  
-  public boolean overlaps(KeyExtent otherExtent) {
-    boolean result = this.extent.overlaps(otherExtent);
-    if (!result && needsToBeChopped(otherExtent))
-      return true;
-    return result;
-  }
-  
-  @Override
-  public String toString() {
-    if (!state.equals(MergeState.NONE))
-      return "Merge " + operation.toString() + " of " + extent + " State: " + state;
-    return "No Merge in progress";
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/MergeState.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/MergeState.java b/server/src/main/java/org/apache/accumulo/server/master/state/MergeState.java
deleted file mode 100644
index 29b6ae3..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/MergeState.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-public enum MergeState {
-  /**
-   * Not merging
-   */
-  NONE,
-  /**
-   * created, stored in zookeeper, other merges are prevented on the table
-   */
-  STARTED,
-  /**
-   * put all matching tablets online, split tablets if we are deleting
-   */
-  SPLITTING,
-  /**
-   * after the tablet server chops the file, it marks the metadata table with a chopped marker
-   */
-  WAITING_FOR_CHOPPED,
-  /**
-   * when the number of chopped tablets in the range matches the number of online tablets in the range, take the tablets offline
-   */
-  WAITING_FOR_OFFLINE,
-  /**
-   * when the number of chopped, offline tablets equals the number of merge tablets, begin the metadata updates
-   */
-  MERGING,
-  /**
-   * merge is complete, the resulting tablet can be brought online, remove the marker in zookeeper
-   */
-  COMPLETE;
-  
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/MergeStats.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/MergeStats.java b/server/src/main/java/org/apache/accumulo/server/master/state/MergeStats.java
deleted file mode 100644
index ca1529e..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/MergeStats.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.KeyExtent;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.metadata.MetadataTable;
-import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
-import org.apache.accumulo.server.cli.ClientOpts;
-import org.apache.accumulo.server.master.state.TabletLocationState.BadLocationStateException;
-import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
-import org.apache.hadoop.io.DataInputBuffer;
-import org.apache.hadoop.io.Text;
-import org.apache.log4j.Logger;
-import org.apache.zookeeper.data.Stat;
-
-public class MergeStats {
-  final static private Logger log = Logger.getLogger(MergeStats.class);
-  MergeInfo info;
-  int hosted = 0;
-  int unassigned = 0;
-  int chopped = 0;
-  int needsToBeChopped = 0;
-  int total = 0;
-  boolean lowerSplit = false;
-  boolean upperSplit = false;
-  
-  public MergeStats(MergeInfo info) {
-    this.info = info;
-    if (info.getState().equals(MergeState.NONE))
-      return;
-    if (info.getExtent().getEndRow() == null)
-      upperSplit = true;
-    if (info.getExtent().getPrevEndRow() == null)
-      lowerSplit = true;
-  }
-  
-  public MergeInfo getMergeInfo() {
-    return info;
-  }
-  
-  public void update(KeyExtent ke, TabletState state, boolean chopped, boolean hasWALs) {
-    if (info.getState().equals(MergeState.NONE))
-      return;
-    if (!upperSplit && info.getExtent().getEndRow().equals(ke.getPrevEndRow())) {
-      log.info("Upper split found");
-      upperSplit = true;
-    }
-    if (!lowerSplit && info.getExtent().getPrevEndRow().equals(ke.getEndRow())) {
-      log.info("Lower split found");
-      lowerSplit = true;
-    }
-    if (!info.overlaps(ke))
-      return;
-    if (info.needsToBeChopped(ke)) {
-      this.needsToBeChopped++;
-      if (chopped) {
-        if (state.equals(TabletState.HOSTED)) {
-          this.chopped++;
-        } else if (!hasWALs) {
-          this.chopped++;
-        }
-      }
-    }
-    this.total++;
-    if (state.equals(TabletState.HOSTED))
-      this.hosted++;
-    if (state.equals(TabletState.UNASSIGNED))
-      this.unassigned++;
-  }
-  
-  public MergeState nextMergeState(Connector connector, CurrentState master) throws Exception {
-    MergeState state = info.getState();
-    if (state == MergeState.NONE)
-      return state;
-    if (total == 0) {
-      log.trace("failed to see any tablets for this range, ignoring " + info.getExtent());
-      return state;
-    }
-    log.info("Computing next merge state for " + info.getExtent() + " which is presently " + state + " isDelete : " + info.isDelete());
-    if (state == MergeState.STARTED) {
-      state = MergeState.SPLITTING;
-    }
-    if (state == MergeState.SPLITTING) {
-      log.info(hosted + " are hosted, total " + total);
-      if (!info.isDelete() && total == 1) {
-        log.info("Merge range is already contained in a single tablet " + info.getExtent());
-        state = MergeState.COMPLETE;
-      } else if (hosted == total) {
-        if (info.isDelete()) {
-          if (!lowerSplit)
-            log.info("Waiting for " + info + " lower split to occur " + info.getExtent());
-          else if (!upperSplit)
-            log.info("Waiting for " + info + " upper split to occur " + info.getExtent());
-          else
-            state = MergeState.WAITING_FOR_CHOPPED;
-        } else {
-          state = MergeState.WAITING_FOR_CHOPPED;
-        }
-      } else {
-        log.info("Waiting for " + hosted + " hosted tablets to be " + total + " " + info.getExtent());
-      }
-    }
-    if (state == MergeState.WAITING_FOR_CHOPPED) {
-      log.info(chopped + " tablets are chopped " + info.getExtent());
-      if (chopped == needsToBeChopped) {
-        state = MergeState.WAITING_FOR_OFFLINE;
-      } else {
-        log.info("Waiting for " + chopped + " chopped tablets to be " + needsToBeChopped + " " + info.getExtent());
-      }
-    }
-    if (state == MergeState.WAITING_FOR_OFFLINE) {
-      if (chopped != needsToBeChopped) {
-        log.warn("Unexpected state: chopped tablets should be " + needsToBeChopped + " was " + chopped + " merge " + info.getExtent());
-        // Perhaps a split occurred after we chopped, but before we went offline: start over
-        state = MergeState.WAITING_FOR_CHOPPED;
-      } else {
-        log.info(chopped + " tablets are chopped, " + unassigned + " are offline " + info.getExtent());
-        if (unassigned == total && chopped == needsToBeChopped) {
-          if (verifyMergeConsistency(connector, master))
-            state = MergeState.MERGING;
-          else
-            log.info("Merge consistency check failed " + info.getExtent());
-        } else {
-          log.info("Waiting for " + unassigned + " unassigned tablets to be " + total + " " + info.getExtent());
-        }
-      }
-    }
-    if (state == MergeState.MERGING) {
-      if (hosted != 0) {
-        // Shouldn't happen
-        log.error("Unexpected state: hosted tablets should be zero " + hosted + " merge " + info.getExtent());
-        state = MergeState.WAITING_FOR_OFFLINE;
-      }
-      if (unassigned != total) {
-        // Shouldn't happen
-        log.error("Unexpected state: unassigned tablets should be " + total + " was " + unassigned + " merge " + info.getExtent());
-        state = MergeState.WAITING_FOR_CHOPPED;
-      }
-      log.info(unassigned + " tablets are unassigned " + info.getExtent());
-    }
-    return state;
-  }
-  
-  private boolean verifyMergeConsistency(Connector connector, CurrentState master) throws TableNotFoundException, IOException {
-    MergeStats verify = new MergeStats(info);
-    KeyExtent extent = info.getExtent();
-    Scanner scanner = connector.createScanner(extent.isMeta() ? RootTable.NAME : MetadataTable.NAME, Authorizations.EMPTY);
-    MetaDataTableScanner.configureScanner(scanner, master);
-    Text start = extent.getPrevEndRow();
-    if (start == null) {
-      start = new Text();
-    }
-    Text tableId = extent.getTableId();
-    Text first = KeyExtent.getMetadataEntry(tableId, start);
-    Range range = new Range(first, false, null, true);
-    scanner.setRange(range);
-    KeyExtent prevExtent = null;
-    
-    log.debug("Scanning range " + range);
-    for (Entry<Key,Value> entry : scanner) {
-      TabletLocationState tls;
-      try {
-        tls = MetaDataTableScanner.createTabletLocationState(entry.getKey(), entry.getValue());
-      } catch (BadLocationStateException e) {
-        log.error(e, e);
-        return false;
-      }
-      log.debug("consistency check: " + tls + " walogs " + tls.walogs.size());
-      if (!tls.extent.getTableId().equals(tableId)) {
-        break;
-      }
-      
-      if (!tls.walogs.isEmpty() && verify.getMergeInfo().needsToBeChopped(tls.extent)) {
-        log.debug("failing consistency: needs to be chopped" + tls.extent);
-        return false;
-      }
-      
-      if (prevExtent == null) {
-        // this is the first tablet observed, it must be offline and its prev row must be less than the start of the merge range
-        if (tls.extent.getPrevEndRow() != null && tls.extent.getPrevEndRow().compareTo(start) > 0) {
-          log.debug("failing consistency: prev row is too high " + start);
-          return false;
-        }
-        
-        if (tls.getState(master.onlineTabletServers()) != TabletState.UNASSIGNED) {
-          log.debug("failing consistency: assigned or hosted " + tls);
-          return false;
-        }
-        
-      } else if (!tls.extent.isPreviousExtent(prevExtent)) {
-        log.debug("hole in " + MetadataTable.NAME);
-        return false;
-      }
-      
-      prevExtent = tls.extent;
-      
-      verify.update(tls.extent, tls.getState(master.onlineTabletServers()), tls.chopped, !tls.walogs.isEmpty());
-      // stop when we've seen the tablet just beyond our range
-      if (tls.extent.getPrevEndRow() != null && extent.getEndRow() != null && tls.extent.getPrevEndRow().compareTo(extent.getEndRow()) > 0) {
-        break;
-      }
-    }
-    log.debug("chopped " + chopped + " v.chopped " + verify.chopped + " unassigned " + unassigned + " v.unassigned " + verify.unassigned + " verify.total "
-        + verify.total);
-    return chopped == verify.chopped && unassigned == verify.unassigned && unassigned == verify.total;
-  }
-  
-  public static void main(String[] args) throws Exception {
-    ClientOpts opts = new ClientOpts();
-    opts.parseArgs(MergeStats.class.getName(), args);
-    
-    Connector conn = opts.getConnector();
-    Map<String,String> tableIdMap = conn.tableOperations().tableIdMap();
-    for (String table : tableIdMap.keySet()) {
-      String tableId = tableIdMap.get(table);
-      String path = ZooUtil.getRoot(conn.getInstance().getInstanceID()) + Constants.ZTABLES + "/" + tableId.toString() + "/merge";
-      MergeInfo info = new MergeInfo();
-      if (ZooReaderWriter.getInstance().exists(path)) {
-        byte[] data = ZooReaderWriter.getInstance().getData(path, new Stat());
-        DataInputBuffer in = new DataInputBuffer();
-        in.reset(data, data.length);
-        info.readFields(in);
-      }
-      System.out.println(String.format("%25s  %10s %10s %s", table, info.state, info.operation, info.extent));
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java b/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
deleted file mode 100644
index 57d38eb..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.MutationsRejectedException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.metadata.MetadataTable;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
-import org.apache.accumulo.core.security.Credentials;
-import org.apache.accumulo.server.client.HdfsZooInstance;
-import org.apache.accumulo.server.security.SystemCredentials;
-import org.apache.hadoop.io.Text;
-
-public class MetaDataStateStore extends TabletStateStore {
-  // private static final Logger log = Logger.getLogger(MetaDataStateStore.class);
-  
-  private static final int THREADS = 4;
-  private static final int LATENCY = 1000;
-  private static final int MAX_MEMORY = 200 * 1024 * 1024;
-  
-  final protected Instance instance;
-  final protected CurrentState state;
-  final protected Credentials credentials;
-  final private String targetTableName;
-  
-  protected MetaDataStateStore(Instance instance, Credentials credentials, CurrentState state, String targetTableName) {
-    this.instance = instance;
-    this.state = state;
-    this.credentials = credentials;
-    this.targetTableName = targetTableName;
-  }
-  
-  public MetaDataStateStore(Instance instance, Credentials credentials, CurrentState state) {
-    this(instance, credentials, state, MetadataTable.NAME);
-  }
-  
-  protected MetaDataStateStore(String tableName) {
-    this(HdfsZooInstance.getInstance(), SystemCredentials.get(), null, tableName);
-  }
-  
-  public MetaDataStateStore() {
-    this(MetadataTable.NAME);
-  }
-  
-  @Override
-  public Iterator<TabletLocationState> iterator() {
-    return new MetaDataTableScanner(instance, credentials, MetadataSchema.TabletsSection.getRange(), state);
-  }
-  
-  @Override
-  public void setLocations(Collection<Assignment> assignments) throws DistributedStoreException {
-    BatchWriter writer = createBatchWriter();
-    try {
-      for (Assignment assignment : assignments) {
-        Mutation m = new Mutation(assignment.tablet.getMetadataEntry());
-        Text cq = assignment.server.asColumnQualifier();
-        m.put(TabletsSection.CurrentLocationColumnFamily.NAME, cq, assignment.server.asMutationValue());
-        m.putDelete(TabletsSection.FutureLocationColumnFamily.NAME, cq);
-        writer.addMutation(m);
-      }
-    } catch (Exception ex) {
-      throw new DistributedStoreException(ex);
-    } finally {
-      try {
-        writer.close();
-      } catch (MutationsRejectedException e) {
-        throw new DistributedStoreException(e);
-      }
-    }
-  }
-  
-  BatchWriter createBatchWriter() {
-    try {
-      return instance.getConnector(credentials.getPrincipal(), credentials.getToken()).createBatchWriter(targetTableName,
-          new BatchWriterConfig().setMaxMemory(MAX_MEMORY).setMaxLatency(LATENCY, TimeUnit.MILLISECONDS).setMaxWriteThreads(THREADS));
-    } catch (TableNotFoundException e) {
-      // ya, I don't think so
-      throw new RuntimeException(e);
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    }
-  }
-  
-  @Override
-  public void setFutureLocations(Collection<Assignment> assignments) throws DistributedStoreException {
-    BatchWriter writer = createBatchWriter();
-    try {
-      for (Assignment assignment : assignments) {
-        Mutation m = new Mutation(assignment.tablet.getMetadataEntry());
-        m.put(TabletsSection.FutureLocationColumnFamily.NAME, assignment.server.asColumnQualifier(), assignment.server.asMutationValue());
-        writer.addMutation(m);
-      }
-    } catch (Exception ex) {
-      throw new DistributedStoreException(ex);
-    } finally {
-      try {
-        writer.close();
-      } catch (MutationsRejectedException e) {
-        throw new DistributedStoreException(e);
-      }
-    }
-  }
-  
-  @Override
-  public void unassign(Collection<TabletLocationState> tablets) throws DistributedStoreException {
-    
-    BatchWriter writer = createBatchWriter();
-    try {
-      for (TabletLocationState tls : tablets) {
-        Mutation m = new Mutation(tls.extent.getMetadataEntry());
-        if (tls.current != null) {
-          m.putDelete(TabletsSection.CurrentLocationColumnFamily.NAME, tls.current.asColumnQualifier());
-        }
-        if (tls.future != null) {
-          m.putDelete(TabletsSection.FutureLocationColumnFamily.NAME, tls.future.asColumnQualifier());
-        }
-        writer.addMutation(m);
-      }
-    } catch (Exception ex) {
-      throw new DistributedStoreException(ex);
-    } finally {
-      try {
-        writer.close();
-      } catch (MutationsRejectedException e) {
-        throw new DistributedStoreException(e);
-      }
-    }
-  }
-  
-  @Override
-  public String name() {
-    return "Normal Tablets";
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java b/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
deleted file mode 100644
index bae614d..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.SortedMap;
-
-import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.ScannerBase;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.KeyExtent;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.iterators.user.WholeRowIterator;
-import org.apache.accumulo.core.metadata.MetadataTable;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ChoppedColumnFamily;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.LogColumnFamily;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.Credentials;
-import org.apache.accumulo.server.master.state.TabletLocationState.BadLocationStateException;
-import org.apache.hadoop.io.Text;
-import org.apache.log4j.Logger;
-
-public class MetaDataTableScanner implements Iterator<TabletLocationState> {
-  private static final Logger log = Logger.getLogger(MetaDataTableScanner.class);
-  
-  BatchScanner mdScanner = null;
-  Iterator<Entry<Key,Value>> iter;
-  
-  public MetaDataTableScanner(Instance instance, Credentials credentials, Range range, CurrentState state) {
-    this(instance, credentials, range, state, MetadataTable.NAME);
-  }
-  
-  MetaDataTableScanner(Instance instance, Credentials credentials, Range range, CurrentState state, String tableName) {
-    // scan over metadata table, looking for tablets in the wrong state based on the live servers and online tables
-    try {
-      Connector connector = instance.getConnector(credentials.getPrincipal(), credentials.getToken());
-      mdScanner = connector.createBatchScanner(tableName, Authorizations.EMPTY, 8);
-      configureScanner(mdScanner, state);
-      mdScanner.setRanges(Collections.singletonList(range));
-      iter = mdScanner.iterator();
-    } catch (Exception ex) {
-      if (mdScanner != null)
-        mdScanner.close();
-      throw new RuntimeException(ex);
-    }
-  }
-  
-  static public void configureScanner(ScannerBase scanner, CurrentState state) {
-    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner);
-    scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
-    scanner.fetchColumnFamily(TabletsSection.FutureLocationColumnFamily.NAME);
-    scanner.fetchColumnFamily(LogColumnFamily.NAME);
-    scanner.fetchColumnFamily(ChoppedColumnFamily.NAME);
-    scanner.addScanIterator(new IteratorSetting(1000, "wholeRows", WholeRowIterator.class));
-    IteratorSetting tabletChange = new IteratorSetting(1001, "tabletChange", TabletStateChangeIterator.class);
-    if (state != null) {
-      TabletStateChangeIterator.setCurrentServers(tabletChange, state.onlineTabletServers());
-      TabletStateChangeIterator.setOnlineTables(tabletChange, state.onlineTables());
-      TabletStateChangeIterator.setMerges(tabletChange, state.merges());
-    }
-    scanner.addScanIterator(tabletChange);
-  }
-  
-  public MetaDataTableScanner(Instance instance, Credentials credentials, Range range) {
-    this(instance, credentials, range, MetadataTable.NAME);
-  }
-  
-  public MetaDataTableScanner(Instance instance, Credentials credentials, Range range, String tableName) {
-    this(instance, credentials, range, null, tableName);
-  }
-  
-  public void close() {
-    if (iter != null) {
-      mdScanner.close();
-      iter = null;
-    }
-  }
-  
-  @Override
-  public void finalize() {
-    close();
-  }
-  
-  @Override
-  public boolean hasNext() {
-    if (iter == null)
-      return false;
-    boolean result = iter.hasNext();
-    if (!result) {
-      close();
-    }
-    return result;
-  }
-  
-  @Override
-  public TabletLocationState next() {
-    try {
-      return fetch();
-    } catch (RuntimeException ex) {
-      // something is wrong with the records in the !METADATA table, just skip over it
-      log.error(ex, ex);
-      mdScanner.close();
-      return null;
-    }
-  }
-  
-  public static TabletLocationState createTabletLocationState(Key k, Value v) throws IOException, BadLocationStateException {
-    final SortedMap<Key,Value> decodedRow = WholeRowIterator.decodeRow(k, v);
-    KeyExtent extent = null;
-    TServerInstance future = null;
-    TServerInstance current = null;
-    TServerInstance last = null;
-    List<Collection<String>> walogs = new ArrayList<Collection<String>>();
-    boolean chopped = false;
-    
-    for (Entry<Key,Value> entry : decodedRow.entrySet()) {
-      Key key = entry.getKey();
-      Text row = key.getRow();
-      Text cf = key.getColumnFamily();
-      Text cq = key.getColumnQualifier();
-      
-      if (cf.compareTo(TabletsSection.FutureLocationColumnFamily.NAME) == 0) {
-        TServerInstance location = new TServerInstance(entry.getValue(), cq);
-        if (future != null) {
-          throw new BadLocationStateException("found two assignments for the same extent " + key.getRow() + ": " + future + " and " + location);
-        }
-        future = location;
-      } else if (cf.compareTo(TabletsSection.CurrentLocationColumnFamily.NAME) == 0) {
-        TServerInstance location = new TServerInstance(entry.getValue(), cq);
-        if (current != null) {
-          throw new BadLocationStateException("found two locations for the same extent " + key.getRow() + ": " + current + " and " + location);
-        }
-        current = location;
-      } else if (cf.compareTo(LogColumnFamily.NAME) == 0) {
-        String[] split = entry.getValue().toString().split("\\|")[0].split(";");
-        walogs.add(Arrays.asList(split));
-      } else if (cf.compareTo(TabletsSection.LastLocationColumnFamily.NAME) == 0) {
-        TServerInstance location = new TServerInstance(entry.getValue(), cq);
-        if (last != null) {
-          throw new BadLocationStateException("found two last locations for the same extent " + key.getRow() + ": " + last + " and " + location);
-        }
-        last = new TServerInstance(entry.getValue(), cq);
-      } else if (cf.compareTo(ChoppedColumnFamily.NAME) == 0) {
-        chopped = true;
-      } else if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.equals(cf, cq)) {
-        extent = new KeyExtent(row, entry.getValue());
-      }
-    }
-    if (extent == null) {
-      log.warn("No prev-row for key extent: " + decodedRow);
-      return null;
-    }
-    return new TabletLocationState(extent, future, current, last, walogs, chopped);
-  }
-  
-  private TabletLocationState fetch() {
-    try {
-      Entry<Key,Value> e = iter.next();
-      return createTabletLocationState(e.getKey(), e.getValue());
-    } catch (IOException ex) {
-      throw new RuntimeException(ex);
-    } catch (BadLocationStateException ex) {
-      throw new RuntimeException(ex);
-    }
-  }
-  
-  @Override
-  public void remove() {
-    throw new RuntimeException("Unimplemented");
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java b/server/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
deleted file mode 100644
index bdf5478..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.util.Iterator;
-
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema;
-import org.apache.accumulo.core.security.Credentials;
-
-public class RootTabletStateStore extends MetaDataStateStore {
-  
-  public RootTabletStateStore(Instance instance, Credentials credentials, CurrentState state) {
-    super(instance, credentials, state, RootTable.NAME);
-  }
-  
-  public RootTabletStateStore() {
-    super(RootTable.NAME);
-  }
-  
-  @Override
-  public Iterator<TabletLocationState> iterator() {
-    return new MetaDataTableScanner(instance, credentials, MetadataSchema.TabletsSection.getRange(), state, RootTable.NAME);
-  }
-  
-  @Override
-  public String name() {
-    return "Metadata Tablets";
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/SetGoalState.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/SetGoalState.java b/server/src/main/java/org/apache/accumulo/server/master/state/SetGoalState.java
deleted file mode 100644
index 0d1b683..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/SetGoalState.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.master.thrift.MasterGoalState;
-import org.apache.accumulo.core.security.SecurityUtil;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
-import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
-import org.apache.accumulo.server.Accumulo;
-import org.apache.accumulo.server.client.HdfsZooInstance;
-import org.apache.accumulo.server.fs.VolumeManager;
-import org.apache.accumulo.server.fs.VolumeManagerImpl;
-import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
-
-public class SetGoalState {
-  
-  /**
-   * Utility program that will change the goal state for the master from the command line.
-   */
-  public static void main(String[] args) throws Exception {
-    if (args.length != 1 || MasterGoalState.valueOf(args[0]) == null) {
-      System.err.println("Usage: accumulo " + SetGoalState.class.getName() + " [NORMAL|SAFE_MODE|CLEAN_STOP]");
-      System.exit(-1);
-    }
-    SecurityUtil.serverLogin();
-
-    VolumeManager fs = VolumeManagerImpl.get();
-    Accumulo.waitForZookeeperAndHdfs(fs);
-    ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZMASTER_GOAL_STATE, args[0].getBytes(),
-        NodeExistsPolicy.OVERWRITE);
-  }
-  
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java b/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java
deleted file mode 100644
index 4de64a8..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.io.Serializable;
-
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
-import org.apache.accumulo.core.util.AddressUtil;
-import org.apache.hadoop.io.Text;
-
-import com.google.common.net.HostAndPort;
-
-/**
- * A tablet is assigned to a tablet server at the given address as long as it is alive and well. When the tablet server is restarted, the instance information
- * it advertises will change. Therefore tablet assignments can be considered out-of-date if the tablet server instance information has been changed.
- * 
- */
-public class TServerInstance implements Comparable<TServerInstance>, Serializable {
-  
-  private static final long serialVersionUID = 1L;
-  
-  private HostAndPort location;
-  private String session;
-  private String cachedStringRepresentation;
-  
-  public TServerInstance(HostAndPort address, String session) {
-    this.location = address;
-    this.session = session;
-    this.cachedStringRepresentation = hostPort() + "[" + session + "]";
-  }
-  
-  public TServerInstance(HostAndPort address, long session) {
-    this(address, Long.toHexString(session));
-  }
-  
-  public TServerInstance(String address, long session) {
-    this(AddressUtil.parseAddress(address), Long.toHexString(session));
-  }
-  
-  public TServerInstance(Value address, Text session) {
-    this(AddressUtil.parseAddress(new String(address.get())), session.toString());
-  }
-  
-  public void putLocation(Mutation m) {
-    m.put(TabletsSection.CurrentLocationColumnFamily.NAME, asColumnQualifier(), asMutationValue());
-  }
-  
-  public void putFutureLocation(Mutation m) {
-    m.put(TabletsSection.FutureLocationColumnFamily.NAME, asColumnQualifier(), asMutationValue());
-  }
-  
-  public void putLastLocation(Mutation m) {
-    m.put(TabletsSection.LastLocationColumnFamily.NAME, asColumnQualifier(), asMutationValue());
-  }
-  
-  public void clearLastLocation(Mutation m) {
-    m.putDelete(TabletsSection.LastLocationColumnFamily.NAME, asColumnQualifier());
-  }
-  
-  @Override
-  public int compareTo(TServerInstance other) {
-    if (this == other)
-      return 0;
-    return this.toString().compareTo(other.toString());
-  }
-  
-  @Override
-  public int hashCode() {
-    return toString().hashCode();
-  }
-  
-  @Override
-  public boolean equals(Object obj) {
-    if (obj instanceof TServerInstance) {
-      return compareTo((TServerInstance) obj) == 0;
-    }
-    return false;
-  }
-  
-  @Override
-  public String toString() {
-    return cachedStringRepresentation;
-  }
-  
-  public int port() {
-    return getLocation().getPort();
-  }
-  
-  public String host() {
-    return getLocation().getHostText();
-  }
-  
-  public String hostPort() {
-    return getLocation().toString();
-  }
-  
-  public Text asColumnQualifier() {
-    return new Text(this.getSession());
-  }
-  
-  public Value asMutationValue() {
-    return new Value(getLocation().toString().getBytes());
-  }
-  
-  public HostAndPort getLocation() {
-    return location;
-  }
-  
-  public String getSession() {
-    return session;
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/TableCounts.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TableCounts.java b/server/src/main/java/org/apache/accumulo/server/master/state/TableCounts.java
deleted file mode 100644
index e1a0158..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TableCounts.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-public class TableCounts {
-  int counts[] = new int[TabletState.values().length];
-  
-  public int unassigned() {
-    return counts[TabletState.UNASSIGNED.ordinal()];
-  }
-  
-  public int assigned() {
-    return counts[TabletState.ASSIGNED.ordinal()];
-  }
-  
-  public int assignedToDeadServers() {
-    return counts[TabletState.ASSIGNED_TO_DEAD_SERVER.ordinal()];
-  }
-  
-  public int hosted() {
-    return counts[TabletState.HOSTED.ordinal()];
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/TableStats.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TableStats.java b/server/src/main/java/org/apache/accumulo/server/master/state/TableStats.java
deleted file mode 100644
index 5895d80..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TableStats.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.hadoop.io.Text;
-
-public class TableStats {
-  private Map<Text,TableCounts> last = new HashMap<Text,TableCounts>();
-  private Map<Text,TableCounts> next;
-  private long startScan = 0;
-  private long endScan = 0;
-  
-  public synchronized void begin() {
-    next = new HashMap<Text,TableCounts>();
-    startScan = System.currentTimeMillis();
-  }
-  
-  public synchronized void update(Text tableId, TabletState state) {
-    TableCounts counts = next.get(tableId);
-    if (counts == null) {
-      counts = new TableCounts();
-      next.put(tableId, counts);
-    }
-    counts.counts[state.ordinal()]++;
-  }
-  
-  public synchronized void end() {
-    last = next;
-    next = null;
-    endScan = System.currentTimeMillis();
-  }
-  
-  public synchronized Map<Text,TableCounts> getLast() {
-    return last;
-  }
-  
-  public synchronized TableCounts getLast(Text tableId) {
-    TableCounts result = last.get(tableId);
-    if (result == null)
-      return new TableCounts();
-    return result;
-  }
-  
-  public synchronized long getScanTime() {
-    if (endScan <= startScan)
-      return System.currentTimeMillis() - startScan;
-    return endScan - startScan;
-  }
-  
-  public synchronized long lastScanFinished() {
-    return endScan;
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/TabletLocationState.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TabletLocationState.java b/server/src/main/java/org/apache/accumulo/server/master/state/TabletLocationState.java
deleted file mode 100644
index bcfaead..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TabletLocationState.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import org.apache.accumulo.core.data.KeyExtent;
-
-/**
- * When a tablet is assigned, we mark its future location. When the tablet is opened, we set its current location. A tablet should never have both a future and
- * current location.
- * 
- * A tablet server is always associated with a unique session id. If the current tablet server has a different session, we know the location information is
- * out-of-date.
- */
-public class TabletLocationState {
-  
-  static public class BadLocationStateException extends Exception {
-    private static final long serialVersionUID = 1L;
-
-    BadLocationStateException(String msg) { super(msg); }
-  }
-  
-  public TabletLocationState(KeyExtent extent, TServerInstance future, TServerInstance current, TServerInstance last, Collection<Collection<String>> walogs,
-      boolean chopped) throws BadLocationStateException {
-    this.extent = extent;
-    this.future = future;
-    this.current = current;
-    this.last = last;
-    if (walogs == null)
-      walogs = Collections.emptyList();
-    this.walogs = walogs;
-    this.chopped = chopped;
-    if (current != null && future != null) {
-      throw new BadLocationStateException(extent + " is both assigned and hosted, which should never happen: " + this);
-    }
-  }
-  
-  final public KeyExtent extent;
-  final public TServerInstance future;
-  final public TServerInstance current;
-  final public TServerInstance last;
-  final public Collection<Collection<String>> walogs;
-  final public boolean chopped;
-  
-  public String toString() {
-    return extent + "@(" + future + "," + current + "," + last + ")" + (chopped ? " chopped" : "");
-  }
-  
-  public TServerInstance getServer() {
-    TServerInstance result = null;
-    if (current != null) {
-      result = current;
-    } else if (future != null) {
-      result = future;
-    } else {
-      result = last;
-    }
-    return result;
-  }
-  
-  public TabletState getState(Set<TServerInstance> liveServers) {
-    TServerInstance server = getServer();
-    if (server == null)
-      return TabletState.UNASSIGNED;
-    if (server.equals(current) || server.equals(future)) {
-      if (liveServers.contains(server))
-        if (server.equals(future)) {
-          return TabletState.ASSIGNED;
-        } else {
-          return TabletState.HOSTED;
-        }
-      else {
-        return TabletState.ASSIGNED_TO_DEAD_SERVER;
-      }
-    }
-    // server == last
-    return TabletState.UNASSIGNED;
-  }
-  
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/TabletMigration.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TabletMigration.java b/server/src/main/java/org/apache/accumulo/server/master/state/TabletMigration.java
deleted file mode 100644
index f0a3664..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TabletMigration.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import org.apache.accumulo.core.data.KeyExtent;
-
-public class TabletMigration {
-  public KeyExtent tablet;
-  public TServerInstance oldServer;
-  public TServerInstance newServer;
-  
-  public TabletMigration(KeyExtent extent, TServerInstance before, TServerInstance after) {
-    this.tablet = extent;
-    this.oldServer = before;
-    this.newServer = after;
-  }
-  
-  public String toString() {
-    return tablet + ": " + oldServer + " -> " + newServer;
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/TabletServerState.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TabletServerState.java b/server/src/main/java/org/apache/accumulo/server/master/state/TabletServerState.java
deleted file mode 100644
index 23f16e3..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TabletServerState.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-
-public enum TabletServerState {
-  // not a valid state, reserved for internal use only
-  RESERVED((byte) (-1)),
-  
-  // the following are normally functioning states
-  NEW((byte) 0),
-  ONLINE((byte) 1),
-  UNRESPONSIVE((byte) 2),
-  DOWN((byte) 3),
-  
-  // the following are bad states and cause tservers to be ignored by the master
-  BAD_SYSTEM_PASSWORD((byte) 101),
-  BAD_VERSION((byte) 102),
-  BAD_INSTANCE((byte) 103),
-  BAD_CONFIG((byte) 104),
-  BAD_VERSION_AND_INSTANCE((byte) 105),
-  BAD_VERSION_AND_CONFIG((byte) 106),
-  BAD_VERSION_AND_INSTANCE_AND_CONFIG((byte) 107),
-  BAD_INSTANCE_AND_CONFIG((byte) 108);
-  
-  private byte id;
-  
-  private static HashMap<Byte,TabletServerState> mapping;
-  private static HashSet<TabletServerState> badStates;
-  
-  static {
-    mapping = new HashMap<Byte,TabletServerState>(TabletServerState.values().length);
-    badStates = new HashSet<TabletServerState>();
-    for (TabletServerState state : TabletServerState.values()) {
-      mapping.put(state.id, state);
-      if (state.id > 99)
-        badStates.add(state);
-    }
-  }
-  
-  private TabletServerState(byte id) {
-    this.id = id;
-  }
-  
-  public byte getId() {
-    return this.id;
-  }
-  
-  public static TabletServerState getStateById(byte id) {
-    if (mapping.containsKey(id))
-      return mapping.get(id);
-    throw new IndexOutOfBoundsException("No such state");
-  }
-  
-  public static Set<TabletServerState> getBadStates() {
-    return Collections.unmodifiableSet(badStates);
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/TabletState.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TabletState.java b/server/src/main/java/org/apache/accumulo/server/master/state/TabletState.java
deleted file mode 100644
index d69ca19..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TabletState.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-public enum TabletState {
-  UNASSIGNED, ASSIGNED, HOSTED, ASSIGNED_TO_DEAD_SERVER
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java b/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
deleted file mode 100644
index ddcdeea..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.KeyExtent;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.iterators.IteratorEnvironment;
-import org.apache.accumulo.core.iterators.SkippingIterator;
-import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
-import org.apache.accumulo.core.util.AddressUtil;
-import org.apache.accumulo.core.util.StringUtil;
-import org.apache.accumulo.server.master.state.TabletLocationState.BadLocationStateException;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.hadoop.io.DataInputBuffer;
-import org.apache.hadoop.io.DataOutputBuffer;
-import org.apache.hadoop.io.Text;
-
-public class TabletStateChangeIterator extends SkippingIterator {
-  
-  private static final String SERVERS_OPTION = "servers";
-  private static final String TABLES_OPTION = "tables";
-  private static final String MERGES_OPTION = "merges";
-  // private static final Logger log = Logger.getLogger(TabletStateChangeIterator.class);
-  
-  Set<TServerInstance> current;
-  Set<String> onlineTables;
-  Map<Text,MergeInfo> merges;
-  
-  @Override
-  public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
-    super.init(source, options, env);
-    current = parseServers(options.get(SERVERS_OPTION));
-    onlineTables = parseTables(options.get(TABLES_OPTION));
-    merges = parseMerges(options.get(MERGES_OPTION));
-  }
-  
-  private Set<String> parseTables(String tables) {
-    if (tables == null)
-      return null;
-    Set<String> result = new HashSet<String>();
-    for (String table : tables.split(","))
-      result.add(table);
-    return result;
-  }
-  
-  private Set<TServerInstance> parseServers(String servers) {
-    if (servers == null)
-      return null;
-    // parse "host:port[INSTANCE]"
-    Set<TServerInstance> result = new HashSet<TServerInstance>();
-    if (servers.length() > 0) {
-      for (String part : servers.split(",")) {
-        String parts[] = part.split("\\[", 2);
-        String hostport = parts[0];
-        String instance = parts[1];
-        if (instance != null && instance.endsWith("]"))
-          instance = instance.substring(0, instance.length() - 1);
-        result.add(new TServerInstance(AddressUtil.parseAddress(hostport), instance));
-      }
-    }
-    return result;
-  }
-  
-  private Map<Text,MergeInfo> parseMerges(String merges) {
-    if (merges == null)
-      return null;
-    try {
-      Map<Text,MergeInfo> result = new HashMap<Text,MergeInfo>();
-      DataInputBuffer buffer = new DataInputBuffer();
-      byte[] data = Base64.decodeBase64(merges.getBytes());
-      buffer.reset(data, data.length);
-      while (buffer.available() > 0) {
-        MergeInfo mergeInfo = new MergeInfo();
-        mergeInfo.readFields(buffer);
-        result.put(mergeInfo.extent.getTableId(), mergeInfo);
-      }
-      return result;
-    } catch (Exception ex) {
-      throw new RuntimeException(ex);
-    }
-  }
-  
-  @Override
-  protected void consume() throws IOException {
-    while (getSource().hasTop()) {
-      Key k = getSource().getTopKey();
-      Value v = getSource().getTopValue();
-      
-      if (onlineTables == null || current == null)
-        return;
-      
-      TabletLocationState tls;
-      try {
-        tls = MetaDataTableScanner.createTabletLocationState(k, v);
-        if (tls == null)
-          return;
-      } catch (BadLocationStateException e) {
-        // maybe the master can do something with a tablet with bad/inconsistent state
-        return;
-      }
-      // we always want data about merges
-      MergeInfo merge = merges.get(tls.extent.getTableId());
-      if (merge != null && merge.getExtent() != null && merge.getExtent().overlaps(tls.extent)) {
-        return;
-      }
-      // is the table supposed to be online or offline?
-      boolean shouldBeOnline = onlineTables.contains(tls.extent.getTableId().toString());
-      
-      switch (tls.getState(current)) {
-        case ASSIGNED:
-          // we always want data about assigned tablets
-          return;
-        case HOSTED:
-          if (!shouldBeOnline)
-            return;
-        case ASSIGNED_TO_DEAD_SERVER:
-          return;
-        case UNASSIGNED:
-          if (shouldBeOnline)
-            return;
-      }
-      // table is in the expected state so don't bother returning any information about it
-      getSource().next();
-    }
-  }
-  
-  @Override
-  public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
-    throw new UnsupportedOperationException();
-  }
-  
-  public static void setCurrentServers(IteratorSetting cfg, Set<TServerInstance> goodServers) {
-    if (goodServers != null) {
-      List<String> servers = new ArrayList<String>();
-      for (TServerInstance server : goodServers)
-        servers.add(server.toString());
-      cfg.addOption(SERVERS_OPTION, StringUtil.join(servers, ","));
-    }
-  }
-  
-  public static void setOnlineTables(IteratorSetting cfg, Set<String> onlineTables) {
-    if (onlineTables != null)
-      cfg.addOption(TABLES_OPTION, StringUtil.join(onlineTables, ","));
-  }
-  
-  public static void setMerges(IteratorSetting cfg, Collection<MergeInfo> merges) {
-    DataOutputBuffer buffer = new DataOutputBuffer();
-    try {
-      for (MergeInfo info : merges) {
-        KeyExtent extent = info.getExtent();
-        if (extent != null && !info.getState().equals(MergeState.NONE)) {
-          info.write(buffer);
-        }
-      }
-    } catch (Exception ex) {
-      throw new RuntimeException(ex);
-    }
-    String encoded = new String(Base64.encodeBase64(Arrays.copyOf(buffer.getData(), buffer.getLength())));
-    cfg.addOption(MERGES_OPTION, encoded);
-  }
-  
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateStore.java b/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateStore.java
deleted file mode 100644
index ed68b4e..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateStore.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-/**
- * Interface for storing information about tablet assignments. There are three implementations:
- * 
- * ZooTabletStateStore: information about the root tablet is stored in ZooKeeper MetaDataStateStore: information about the other tablets are stored in the
- * metadata table
- * 
- */
-public abstract class TabletStateStore implements Iterable<TabletLocationState> {
-  
-  /**
-   * Identifying name for this tablet state store.
-   */
-  abstract public String name();
-  
-  /**
-   * Scan the information about the tablets covered by this store
-   */
-  @Override
-  abstract public Iterator<TabletLocationState> iterator();
-  
-  /**
-   * Store the assigned locations in the data store.
-   * 
-   * @param assignments
-   * @throws DistributedStoreException
-   */
-  abstract public void setFutureLocations(Collection<Assignment> assignments) throws DistributedStoreException;
-  
-  /**
-   * Tablet servers will update the data store with the location when they bring the tablet online
-   * 
-   * @param assignments
-   * @throws DistributedStoreException
-   */
-  abstract public void setLocations(Collection<Assignment> assignments) throws DistributedStoreException;
-  
-  /**
-   * Mark the tablets as having no known or future location.
-   * 
-   * @param tablets
-   *          the tablets' current information
-   * @throws DistributedStoreException
-   */
-  abstract public void unassign(Collection<TabletLocationState> tablets) throws DistributedStoreException;
-  
-  public static void unassign(TabletLocationState tls) throws DistributedStoreException {
-    TabletStateStore store;
-    if (tls.extent.isRootTablet()) {
-      store = new ZooTabletStateStore();
-    } else if (tls.extent.isMeta()) {
-      store = new RootTabletStateStore();
-    } else {
-      store = new MetaDataStateStore();
-    }
-    store.unassign(Collections.singletonList(tls));
-  }
-  
-  public static void setLocation(Assignment assignment) throws DistributedStoreException {
-    TabletStateStore store;
-    if (assignment.tablet.isRootTablet()) {
-      store = new ZooTabletStateStore();
-    } else if (assignment.tablet.isMeta()) {
-      store = new RootTabletStateStore();
-    } else {
-      store = new MetaDataStateStore();
-    }
-    store.setLocations(Collections.singletonList(assignment));
-  }
-  
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java b/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
deleted file mode 100644
index bce6681..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.accumulo.core.zookeeper.ZooUtil;
-import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
-import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
-import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
-import org.apache.accumulo.server.client.HdfsZooInstance;
-import org.apache.accumulo.server.zookeeper.ZooCache;
-import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
-import org.apache.log4j.Logger;
-
-public class ZooStore implements DistributedStore {
-  
-  private static final Logger log = Logger.getLogger(ZooStore.class);
-  
-  String basePath;
-  
-  ZooCache cache = new ZooCache();
-  
-  public ZooStore(String basePath) throws IOException {
-    if (basePath.endsWith("/"))
-      basePath = basePath.substring(0, basePath.length() - 1);
-    this.basePath = basePath;
-  }
-  
-  public ZooStore() throws IOException {
-    this(ZooUtil.getRoot(HdfsZooInstance.getInstance().getInstanceID()));
-  }
-  
-  @Override
-  public byte[] get(String path) throws DistributedStoreException {
-    try {
-      return cache.get(relative(path));
-    } catch (Exception ex) {
-      throw new DistributedStoreException(ex);
-    }
-  }
-  
-  private String relative(String path) {
-    return basePath + path;
-  }
-  
-  @Override
-  public List<String> getChildren(String path) throws DistributedStoreException {
-    try {
-      return cache.getChildren(relative(path));
-    } catch (Exception ex) {
-      throw new DistributedStoreException(ex);
-    }
-  }
-  
-  @Override
-  public void put(String path, byte[] bs) throws DistributedStoreException {
-    try {
-      path = relative(path);
-      ZooReaderWriter.getInstance().putPersistentData(path, bs, NodeExistsPolicy.OVERWRITE);
-      cache.clear();
-      log.debug("Wrote " + new String(bs) + " to " + path);
-    } catch (Exception ex) {
-      throw new DistributedStoreException(ex);
-    }
-  }
-  
-  @Override
-  public void remove(String path) throws DistributedStoreException {
-    try {
-      log.debug("Removing " + path);
-      path = relative(path);
-      IZooReaderWriter zoo = ZooReaderWriter.getInstance();
-      if (zoo.exists(path))
-        zoo.recursiveDelete(path, NodeMissingPolicy.SKIP);
-      cache.clear();
-    } catch (Exception ex) {
-      throw new DistributedStoreException(ex);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java b/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
deleted file mode 100644
index 7c0bf1d..0000000
--- a/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.master.state;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.server.util.MetadataTableUtil;
-import org.apache.commons.lang.NotImplementedException;
-import org.apache.log4j.Logger;
-
-import com.google.common.net.HostAndPort;
-
-public class ZooTabletStateStore extends TabletStateStore {
-  
-  private static final Logger log = Logger.getLogger(ZooTabletStateStore.class);
-  final private DistributedStore store;
-  
-  public ZooTabletStateStore(DistributedStore store) {
-    this.store = store;
-  }
-  
-  public ZooTabletStateStore() throws DistributedStoreException {
-    try {
-      store = new ZooStore();
-    } catch (IOException ex) {
-      throw new DistributedStoreException(ex);
-    }
-  }
-  
-  @Override
-  public Iterator<TabletLocationState> iterator() {
-    return new Iterator<TabletLocationState>() {
-      boolean finished = false;
-      
-      @Override
-      public boolean hasNext() {
-        return !finished;
-      }
-      
-      @Override
-      public TabletLocationState next() {
-        finished = true;
-        try {
-          byte[] future = store.get(RootTable.ZROOT_TABLET_FUTURE_LOCATION);
-          byte[] current = store.get(RootTable.ZROOT_TABLET_LOCATION);
-          byte[] last = store.get(RootTable.ZROOT_TABLET_LAST_LOCATION);
-          
-          TServerInstance currentSession = null;
-          TServerInstance futureSession = null;
-          TServerInstance lastSession = null;
-          
-          if (future != null)
-            futureSession = parse(future);
-          
-          if (last != null)
-            lastSession = parse(last);
-          
-          if (current != null) {
-            currentSession = parse(current);
-            futureSession = null;
-          }
-          List<Collection<String>> logs = new ArrayList<Collection<String>>();
-          for (String entry : store.getChildren(RootTable.ZROOT_TABLET_WALOGS)) {
-            byte[] logInfo = store.get(RootTable.ZROOT_TABLET_WALOGS + "/" + entry);
-            if (logInfo != null) {
-              MetadataTableUtil.LogEntry logEntry = new MetadataTableUtil.LogEntry();
-              logEntry.fromBytes(logInfo);
-              logs.add(logEntry.logSet);
-              log.debug("root tablet logSet " + logEntry.logSet);
-            }
-          }
-          TabletLocationState result = new TabletLocationState(RootTable.EXTENT, futureSession, currentSession, lastSession, logs, false);
-          log.debug("Returning root tablet state: " + result);
-          return result;
-        } catch (Exception ex) {
-          throw new RuntimeException(ex);
-        }
-      }
-      
-      @Override
-      public void remove() {
-        throw new NotImplementedException();
-      }
-    };
-  }
-  
-  protected TServerInstance parse(byte[] current) {
-    String str = new String(current);
-    String[] parts = str.split("[|]", 2);
-    HostAndPort address = HostAndPort.fromString(parts[0]);
-    if (parts.length > 1 && parts[1] != null && parts[1].length() > 0) {
-      return new TServerInstance(address, parts[1]);
-    } else {
-      // a 1.2 location specification: DO NOT WANT
-      return null;
-    }
-  }
-  
-  @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");
-    String value = assignment.server.getLocation() + "|" + assignment.server.getSession();
-    Iterator<TabletLocationState> currentIter = iterator();
-    TabletLocationState current = currentIter.next();
-    if (current.current != null) {
-      throw new DistributedStoreException("Trying to set the root tablet location: it is already set to " + current.current);
-    }
-    store.put(RootTable.ZROOT_TABLET_FUTURE_LOCATION, value.getBytes());
-  }
-  
-  @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");
-    String value = assignment.server.getLocation() + "|" + assignment.server.getSession();
-    Iterator<TabletLocationState> currentIter = iterator();
-    TabletLocationState current = currentIter.next();
-    if (current.current != null) {
-      throw new DistributedStoreException("Trying to set the root tablet location: it is already set to " + current.current);
-    }
-    if (!current.future.equals(assignment.server)) {
-      throw new DistributedStoreException("Root tablet is already assigned to " + current.future);
-    }
-    store.put(RootTable.ZROOT_TABLET_LOCATION, value.getBytes());
-    store.put(RootTable.ZROOT_TABLET_LAST_LOCATION, value.getBytes());
-    // Make the following unnecessary by making the entire update atomic
-    store.remove(RootTable.ZROOT_TABLET_FUTURE_LOCATION);
-    log.debug("Put down root tablet location");
-  }
-  
-  @Override
-  public void unassign(Collection<TabletLocationState> tablets) 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");
-    store.remove(RootTable.ZROOT_TABLET_LOCATION);
-    store.remove(RootTable.ZROOT_TABLET_FUTURE_LOCATION);
-    log.debug("unassign root tablet location");
-  }
-  
-  @Override
-  public String name() {
-    return "Root Table";
-  }
-  
-}


Mime
View raw message