You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2013/09/07 05:28:59 UTC
[56/59] [abbrv] git commit: ACCUMULO-658 consistent package names to
avoid overlapped sealed jars
ACCUMULO-658 consistent package names to avoid overlapped sealed jars
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/a10587ed
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/a10587ed
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/a10587ed
Branch: refs/heads/ACCUMULO-210
Commit: a10587eddbfd31747b3d077ae0f58e7dbdaeb54b
Parents: 173f12f
Author: Christopher Tubbs <ct...@apache.org>
Authored: Tue Aug 6 17:35:48 2013 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri Sep 6 23:24:39 2013 -0400
----------------------------------------------------------------------
.../minicluster/MiniAccumuloCluster.java | 4 +-
.../apache/accumulo/master/LiveTServerSet.java | 398 --
.../accumulo/master/state/Assignment.java | 30 -
.../accumulo/master/state/CurrentState.java | 30 -
.../accumulo/master/state/DeadServerList.java | 80 -
.../accumulo/master/state/DistributedStore.java | 34 -
.../master/state/DistributedStoreException.java | 34 -
.../apache/accumulo/master/state/MergeInfo.java | 107 -
.../accumulo/master/state/MergeState.java | 49 -
.../master/state/MetaDataStateStore.java | 160 -
.../master/state/MetaDataTableScanner.java | 196 -
.../master/state/RootTabletStateStore.java | 48 -
.../accumulo/master/state/TServerInstance.java | 127 -
.../master/state/TabletLocationState.java | 97 -
.../master/state/TabletServerState.java | 76 -
.../accumulo/master/state/TabletState.java | 21 -
.../master/state/TabletStateChangeIterator.java | 188 -
.../accumulo/master/state/TabletStateStore.java | 94 -
.../apache/accumulo/master/state/ZooStore.java | 96 -
.../master/state/ZooTabletStateStore.java | 176 -
.../master/tableOps/CompactionIterators.java | 106 -
.../server/constraints/MetadataConstraints.java | 315 ++
.../apache/accumulo/server/init/Initialize.java | 523 +++
.../iterators/MetadataBulkLoadFilter.java | 91 +
.../accumulo/server/master/LiveTServerSet.java | 398 ++
.../server/master/state/Assignment.java | 30 +
.../server/master/state/CurrentState.java | 30 +
.../server/master/state/DeadServerList.java | 80 +
.../server/master/state/DistributedStore.java | 34 +
.../master/state/DistributedStoreException.java | 34 +
.../accumulo/server/master/state/MergeInfo.java | 107 +
.../server/master/state/MergeState.java | 49 +
.../server/master/state/MetaDataStateStore.java | 160 +
.../master/state/MetaDataTableScanner.java | 196 +
.../master/state/RootTabletStateStore.java | 48 +
.../server/master/state/TServerInstance.java | 127 +
.../master/state/TabletLocationState.java | 97 +
.../server/master/state/TabletServerState.java | 76 +
.../server/master/state/TabletState.java | 21 +
.../master/state/TabletStateChangeIterator.java | 188 +
.../server/master/state/TabletStateStore.java | 94 +
.../accumulo/server/master/state/ZooStore.java | 96 +
.../master/state/ZooTabletStateStore.java | 176 +
.../master/tableOps/CompactionIterators.java | 106 +
.../accumulo/server/tablets/TabletTime.java | 228 ++
.../server/tablets/UniqueNameAllocator.java | 79 +
.../server/tabletserver/TabletTime.java | 224 -
.../tabletserver/UniqueNameAllocator.java | 79 -
.../org/apache/accumulo/server/util/Admin.java | 278 ++
.../server/util/FindOfflineTablets.java | 129 +
.../apache/accumulo/server/util/Initialize.java | 522 ---
.../server/util/MasterMetadataUtil.java | 2 +-
.../accumulo/server/util/TabletOperations.java | 2 +-
.../constraints/MetadataConstraints.java | 315 --
.../iterators/MetadataBulkLoadFilter.java | 91 -
.../constraints/MetadataConstraintsTest.java | 2 +-
.../iterators/MetadataBulkLoadFilterTest.java | 2 +-
.../java/org/apache/accumulo/master/Master.java | 27 +-
.../accumulo/master/TabletGroupWatcher.java | 20 +-
.../master/balancer/ChaoticLoadBalancer.java | 2 +-
.../master/balancer/DefaultLoadBalancer.java | 2 +-
.../master/balancer/TableLoadBalancer.java | 2 +-
.../master/balancer/TabletBalancer.java | 2 +-
.../accumulo/master/state/MergeStats.java | 16 +-
.../accumulo/master/state/TableCounts.java | 2 +-
.../accumulo/master/state/TableStats.java | 2 +-
.../accumulo/master/state/TabletMigration.java | 2 +-
.../accumulo/master/tableOps/BulkImport.java | 6 +-
.../accumulo/master/tableOps/CompactRange.java | 5 +-
.../accumulo/master/tableOps/CreateTable.java | 2 +-
.../accumulo/master/tableOps/DeleteTable.java | 6 +-
.../accumulo/master/tableOps/ImportTable.java | 2 +-
.../accumulo/master/tableOps/TableRangeOp.java | 6 +-
.../master/tserverOps/ShutdownTServer.java | 4 +-
.../apache/accumulo/master/TestMergeState.java | 16 +-
.../balancer/ChaoticLoadBalancerTest.java | 2 +-
.../balancer/DefaultLoadBalancerTest.java | 2 +-
.../master/balancer/TableLoadBalancerTest.java | 2 +-
.../accumulo/master/state/MergeInfoTest.java | 10 +-
.../master/state/RootTabletStateStoreTest.java | 14 +-
.../monitor/servlets/OperationServlet.java | 2 +-
.../monitor/servlets/TServersServlet.java | 2 +-
.../monitor/servlets/TablesServlet.java | 4 +-
.../accumulo/monitor/servlets/XMLServlet.java | 2 +-
.../org/apache/accumulo/server/util/Admin.java | 278 --
.../server/tabletserver/CompactionWatcher.java | 109 -
.../tabletserver/BulkFailedCopyProcessor.java | 72 -
.../server/tabletserver/CompactionQueue.java | 148 -
.../server/tabletserver/CompactionStats.java | 59 -
.../accumulo/server/tabletserver/Compactor.java | 542 ---
.../tabletserver/ConditionalMutationSet.java | 91 -
.../tabletserver/EndOfTableException.java | 26 -
.../server/tabletserver/FileManager.java | 561 ---
.../tabletserver/HoldTimeoutException.java | 25 -
.../server/tabletserver/InMemoryMap.java | 762 ----
.../tabletserver/LargestFirstMemoryManager.java | 200 -
.../accumulo/server/tabletserver/MemKey.java | 77 -
.../accumulo/server/tabletserver/MemValue.java | 93 -
.../tabletserver/MemoryManagementActions.java | 25 -
.../server/tabletserver/MemoryManager.java | 55 -
.../server/tabletserver/MinorCompactor.java | 146 -
.../server/tabletserver/MutationLog.java | 99 -
.../accumulo/server/tabletserver/NativeMap.java | 717 ----
.../accumulo/server/tabletserver/Rate.java | 60 -
.../accumulo/server/tabletserver/RowLocks.java | 162 -
.../accumulo/server/tabletserver/TLevel.java | 36 -
.../accumulo/server/tabletserver/Tablet.java | 3840 -----------------
.../tabletserver/TabletIteratorEnvironment.java | 111 -
.../server/tabletserver/TabletMutations.java | 47 -
.../server/tabletserver/TabletServer.java | 3796 -----------------
.../tabletserver/TabletServerConstants.java | 28 -
.../TabletServerResourceManager.java | 804 ----
.../server/tabletserver/TabletState.java | 29 -
.../server/tabletserver/TabletStatsKeeper.java | 113 -
.../tabletserver/TooManyFilesException.java | 28 -
.../server/tabletserver/log/DfsLogger.java | 455 ---
.../server/tabletserver/log/LogSorter.java | 272 --
.../server/tabletserver/log/MultiReader.java | 167 -
.../tabletserver/log/MutationReceiver.java | 23 -
.../tabletserver/log/SortedLogRecovery.java | 241 --
.../tabletserver/log/TabletServerLogger.java | 430 --
.../mastermessage/MasterMessage.java | 28 -
.../mastermessage/SplitReportMessage.java | 55 -
.../mastermessage/TabletStatusMessage.java | 40 -
.../tabletserver/metrics/TabletServerMBean.java | 50 -
.../metrics/TabletServerMinCMetrics.java | 88 -
.../metrics/TabletServerMinCMetricsMBean.java | 42 -
.../metrics/TabletServerScanMetrics.java | 88 -
.../metrics/TabletServerScanMetricsMBean.java | 42 -
.../metrics/TabletServerUpdateMetrics.java | 134 -
.../metrics/TabletServerUpdateMetricsMBean.java | 66 -
.../tserver/BulkFailedCopyProcessor.java | 72 +
.../accumulo/tserver/CompactionQueue.java | 148 +
.../accumulo/tserver/CompactionStats.java | 59 +
.../accumulo/tserver/CompactionWatcher.java | 109 +
.../org/apache/accumulo/tserver/Compactor.java | 542 +++
.../tserver/ConditionalMutationSet.java | 91 +
.../accumulo/tserver/EndOfTableException.java | 26 +
.../apache/accumulo/tserver/FileManager.java | 561 +++
.../accumulo/tserver/HoldTimeoutException.java | 25 +
.../apache/accumulo/tserver/InMemoryMap.java | 762 ++++
.../tserver/LargestFirstMemoryManager.java | 200 +
.../org/apache/accumulo/tserver/MemKey.java | 77 +
.../org/apache/accumulo/tserver/MemValue.java | 93 +
.../tserver/MemoryManagementActions.java | 25 +
.../apache/accumulo/tserver/MemoryManager.java | 55 +
.../apache/accumulo/tserver/MinorCompactor.java | 146 +
.../apache/accumulo/tserver/MutationLog.java | 99 +
.../org/apache/accumulo/tserver/NativeMap.java | 717 ++++
.../java/org/apache/accumulo/tserver/Rate.java | 60 +
.../org/apache/accumulo/tserver/RowLocks.java | 162 +
.../org/apache/accumulo/tserver/TLevel.java | 36 +
.../org/apache/accumulo/tserver/Tablet.java | 3842 ++++++++++++++++++
.../tserver/TabletIteratorEnvironment.java | 111 +
.../accumulo/tserver/TabletMutations.java | 47 +
.../apache/accumulo/tserver/TabletServer.java | 3797 +++++++++++++++++
.../accumulo/tserver/TabletServerConstants.java | 28 +
.../tserver/TabletServerResourceManager.java | 804 ++++
.../apache/accumulo/tserver/TabletState.java | 29 +
.../accumulo/tserver/TabletStatsKeeper.java | 113 +
.../accumulo/tserver/TooManyFilesException.java | 28 +
.../apache/accumulo/tserver/log/DfsLogger.java | 455 +++
.../apache/accumulo/tserver/log/LogSorter.java | 272 ++
.../accumulo/tserver/log/MultiReader.java | 167 +
.../accumulo/tserver/log/MutationReceiver.java | 23 +
.../accumulo/tserver/log/SortedLogRecovery.java | 241 ++
.../tserver/log/TabletServerLogger.java | 430 ++
.../accumulo/tserver/logger/LogReader.java | 4 +-
.../tserver/mastermessage/MasterMessage.java | 28 +
.../mastermessage/SplitReportMessage.java | 55 +
.../mastermessage/TabletStatusMessage.java | 40 +
.../tserver/metrics/TabletServerMBean.java | 50 +
.../metrics/TabletServerMinCMetrics.java | 88 +
.../metrics/TabletServerMinCMetricsMBean.java | 42 +
.../metrics/TabletServerScanMetrics.java | 88 +
.../metrics/TabletServerScanMetricsMBean.java | 42 +
.../metrics/TabletServerUpdateMetrics.java | 134 +
.../metrics/TabletServerUpdateMetricsMBean.java | 66 +
.../tabletserver/CheckTabletMetadataTest.java | 122 -
.../server/tabletserver/InMemoryMapTest.java | 492 ---
.../tabletserver/log/MultiReaderTest.java | 146 -
.../tabletserver/log/SortedLogRecoveryTest.java | 602 ---
.../tserver/CheckTabletMetadataTest.java | 123 +
.../accumulo/tserver/InMemoryMapTest.java | 492 +++
.../accumulo/tserver/log/MultiReaderTest.java | 146 +
.../tserver/log/SortedLogRecoveryTest.java | 602 +++
server/utils/pom.xml | 2 +-
.../accumulo/server/metanalysis/FilterMeta.java | 92 -
.../accumulo/server/metanalysis/FindTablet.java | 66 -
.../accumulo/server/metanalysis/IndexMeta.java | 176 -
.../server/metanalysis/LogFileInputFormat.java | 116 -
.../server/metanalysis/LogFileOutputFormat.java | 66 -
.../server/metanalysis/PrintEvents.java | 99 -
.../server/metanalysis/package-info.java | 34 -
.../server/util/FindOfflineTablets.java | 132 -
.../accumulo/utils/metanalysis/FilterMeta.java | 92 +
.../accumulo/utils/metanalysis/FindTablet.java | 66 +
.../accumulo/utils/metanalysis/IndexMeta.java | 176 +
.../utils/metanalysis/LogFileInputFormat.java | 116 +
.../utils/metanalysis/LogFileOutputFormat.java | 66 +
.../accumulo/utils/metanalysis/PrintEvents.java | 99 +
.../utils/metanalysis/package-info.java | 34 +
.../accumulo/test/EstimateInMemMapOverhead.java | 2 +-
.../accumulo/test/NativeMapConcurrencyTest.java | 2 +-
.../accumulo/test/NativeMapPerformanceTest.java | 2 +-
.../accumulo/test/NativeMapStressTest.java | 2 +-
.../accumulo/test/functional/NativeMapTest.java | 2 +-
.../test/functional/SplitRecoveryTest.java | 8 +-
.../metadata/MetadataBatchScanTest.java | 2 +-
.../test/performance/thrift/NullTserver.java | 10 +-
.../randomwalk/concurrent/StopTabletServer.java | 2 +-
.../test/functional/HalfDeadTServerIT.java | 6 +-
212 files changed, 20998 insertions(+), 20990 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
index aff4271..05d305c 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
@@ -49,12 +49,12 @@ import org.apache.accumulo.core.util.Pair;
import org.apache.accumulo.core.util.UtilWaitThread;
import org.apache.accumulo.master.Master;
import org.apache.accumulo.master.state.SetGoalState;
-import org.apache.accumulo.server.tabletserver.TabletServer;
-import org.apache.accumulo.server.util.Initialize;
+import org.apache.accumulo.server.init.Initialize;
import org.apache.accumulo.server.util.PortUtils;
import org.apache.accumulo.server.util.time.SimpleTimer;
import org.apache.accumulo.start.Main;
import org.apache.accumulo.start.classloader.vfs.MiniDFSUtil;
+import org.apache.accumulo.tserver.TabletServer;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.DFSConfigKeys;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/server/base/src/main/java/org/apache/accumulo/master/LiveTServerSet.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/LiveTServerSet.java b/server/base/src/main/java/org/apache/accumulo/master/LiveTServerSet.java
deleted file mode 100644
index 59ab8c8..0000000
--- a/server/base/src/main/java/org/apache/accumulo/master/LiveTServerSet.java
+++ /dev/null
@@ -1,398 +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.master;
-
-import static org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy.SKIP;
-
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.data.KeyExtent;
-import org.apache.accumulo.core.master.thrift.TabletServerStatus;
-import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException;
-import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
-import org.apache.accumulo.core.util.AddressUtil;
-import org.apache.accumulo.core.util.ServerServices;
-import org.apache.accumulo.core.util.ThriftUtil;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
-import org.apache.accumulo.master.state.TServerInstance;
-import org.apache.accumulo.server.security.SystemCredentials;
-import org.apache.accumulo.server.util.Halt;
-import org.apache.accumulo.server.util.time.SimpleTimer;
-import org.apache.accumulo.server.zookeeper.ZooCache;
-import org.apache.accumulo.server.zookeeper.ZooLock;
-import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
-import org.apache.accumulo.trace.instrument.Tracer;
-import org.apache.hadoop.io.Text;
-import org.apache.log4j.Logger;
-import org.apache.thrift.TException;
-import org.apache.thrift.transport.TTransport;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.KeeperException.NoNodeException;
-import org.apache.zookeeper.KeeperException.NotEmptyException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.data.Stat;
-
-public class LiveTServerSet implements Watcher {
-
- public interface Listener {
- void update(LiveTServerSet current, Set<TServerInstance> deleted, Set<TServerInstance> added);
- }
-
- private static final Logger log = Logger.getLogger(LiveTServerSet.class);
-
- private final Listener cback;
- private final Instance instance;
- private final AccumuloConfiguration conf;
- private ZooCache zooCache;
-
- public class TServerConnection {
- private final InetSocketAddress address;
-
- public TServerConnection(InetSocketAddress addr) throws TException {
- address = addr;
- }
-
- private String lockString(ZooLock mlock) {
- return mlock.getLockID().serialize(ZooUtil.getRoot(instance) + Constants.ZMASTER_LOCK);
- }
-
- public void assignTablet(ZooLock lock, KeyExtent extent) throws TException {
- TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
- try {
- client.loadTablet(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), extent.toThrift());
- } finally {
- ThriftUtil.returnClient(client);
- }
- }
-
- public void unloadTablet(ZooLock lock, KeyExtent extent, boolean save) throws TException {
- TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
- try {
- client.unloadTablet(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), extent.toThrift(), save);
- } finally {
- ThriftUtil.returnClient(client);
- }
- }
-
- public TabletServerStatus getTableMap(boolean usePooledConnection) throws TException, ThriftSecurityException {
-
- if (usePooledConnection == true)
- throw new UnsupportedOperationException();
-
- TTransport transport = ThriftUtil.createTransport(address, conf);
-
- try {
- TabletClientService.Client client = ThriftUtil.createClient(new TabletClientService.Client.Factory(), transport);
- return client.getTabletServerStatus(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance));
- } finally {
- if (transport != null)
- transport.close();
- }
- }
-
- public void halt(ZooLock lock) throws TException, ThriftSecurityException {
- TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
- try {
- client.halt(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock));
- } finally {
- ThriftUtil.returnClient(client);
- }
- }
-
- public void fastHalt(ZooLock lock) throws TException {
- TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
- try {
- client.fastHalt(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock));
- } finally {
- ThriftUtil.returnClient(client);
- }
- }
-
- public void flush(ZooLock lock, String tableId, byte[] startRow, byte[] endRow) throws TException {
- TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
- try {
- client.flush(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), tableId,
- startRow == null ? null : ByteBuffer.wrap(startRow), endRow == null ? null : ByteBuffer.wrap(endRow));
- } finally {
- ThriftUtil.returnClient(client);
- }
- }
-
- public void chop(ZooLock lock, KeyExtent extent) throws TException {
- TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
- try {
- client.chop(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), extent.toThrift());
- } finally {
- ThriftUtil.returnClient(client);
- }
- }
-
- public void splitTablet(ZooLock lock, KeyExtent extent, Text splitPoint) throws TException, ThriftSecurityException, NotServingTabletException {
- TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
- try {
- client.splitTablet(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), extent.toThrift(),
- ByteBuffer.wrap(splitPoint.getBytes(), 0, splitPoint.getLength()));
- } finally {
- ThriftUtil.returnClient(client);
- }
- }
-
- public void flushTablet(ZooLock lock, KeyExtent extent) throws TException {
- TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
- try {
- client.flushTablet(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), extent.toThrift());
- } finally {
- ThriftUtil.returnClient(client);
- }
- }
-
- public void compact(ZooLock lock, String tableId, byte[] startRow, byte[] endRow) throws TException {
- TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
- try {
- client.compact(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance), lockString(lock), tableId,
- startRow == null ? null : ByteBuffer.wrap(startRow), endRow == null ? null : ByteBuffer.wrap(endRow));
- } finally {
- ThriftUtil.returnClient(client);
- }
- }
-
- public boolean isActive(long tid) throws TException {
- TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
- try {
- return client.isActive(Tracer.traceInfo(), tid);
- } finally {
- ThriftUtil.returnClient(client);
- }
- }
-
- }
-
- static class TServerInfo {
- TServerConnection connection;
- TServerInstance instance;
-
- TServerInfo(TServerInstance instance, TServerConnection connection) {
- this.connection = connection;
- this.instance = instance;
- }
- };
-
- // The set of active tservers with locks, indexed by their name in zookeeper
- private Map<String,TServerInfo> current = new HashMap<String,TServerInfo>();
- // as above, indexed by TServerInstance
- private Map<TServerInstance,TServerInfo> currentInstances = new HashMap<TServerInstance,TServerInfo>();
-
- // The set of entries in zookeeper without locks, and the first time each was noticed
- private Map<String,Long> locklessServers = new HashMap<String,Long>();
-
- public LiveTServerSet(Instance instance, AccumuloConfiguration conf, Listener cback) {
- this.cback = cback;
- this.instance = instance;
- this.conf = conf;
-
- }
-
- public synchronized ZooCache getZooCache() {
- if (zooCache == null)
- zooCache = new ZooCache(this);
- return zooCache;
- }
-
- public synchronized void startListeningForTabletServerChanges() {
- scanServers();
- SimpleTimer.getInstance().schedule(new Runnable() {
- @Override
- public void run() {
- scanServers();
- }
- }, 0, 5000);
- }
-
- public synchronized void scanServers() {
- try {
- final Set<TServerInstance> updates = new HashSet<TServerInstance>();
- final Set<TServerInstance> doomed = new HashSet<TServerInstance>();
-
- final String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
-
- HashSet<String> all = new HashSet<String>(current.keySet());
- all.addAll(getZooCache().getChildren(path));
-
- locklessServers.keySet().retainAll(all);
-
- for (String zPath : all) {
- checkServer(updates, doomed, path, zPath);
- }
-
- // log.debug("Current: " + current.keySet());
- if (!doomed.isEmpty() || !updates.isEmpty())
- this.cback.update(this, doomed, updates);
- } catch (Exception ex) {
- log.error(ex, ex);
- }
- }
-
- private void deleteServerNode(String serverNode) throws InterruptedException, KeeperException {
- try {
- ZooReaderWriter.getInstance().delete(serverNode, -1);
- } catch (NotEmptyException ex) {
- // race condition: tserver created the lock after our last check; we'll see it at the next check
- } catch (NoNodeException nne) {
- // someone else deleted it
- }
- }
-
- private synchronized void checkServer(final Set<TServerInstance> updates, final Set<TServerInstance> doomed, final String path, final String zPath)
- throws TException, InterruptedException, KeeperException {
-
- TServerInfo info = current.get(zPath);
-
- final String lockPath = path + "/" + zPath;
- Stat stat = new Stat();
- byte[] lockData = ZooLock.getLockData(getZooCache(), lockPath, stat);
-
- if (lockData == null) {
- if (info != null) {
- doomed.add(info.instance);
- current.remove(zPath);
- currentInstances.remove(info.instance);
- }
-
- Long firstSeen = locklessServers.get(zPath);
- if (firstSeen == null) {
- locklessServers.put(zPath, System.currentTimeMillis());
- } else if (System.currentTimeMillis() - firstSeen > 10 * 60 * 1000) {
- deleteServerNode(path + "/" + zPath);
- locklessServers.remove(zPath);
- }
- } else {
- locklessServers.remove(zPath);
- ServerServices services = new ServerServices(new String(lockData));
- InetSocketAddress client = services.getAddress(ServerServices.Service.TSERV_CLIENT);
- TServerInstance instance = new TServerInstance(client, stat.getEphemeralOwner());
-
- if (info == null) {
- updates.add(instance);
- TServerInfo tServerInfo = new TServerInfo(instance, new TServerConnection(client));
- current.put(zPath, tServerInfo);
- currentInstances.put(instance, tServerInfo);
- } else if (!info.instance.equals(instance)) {
- doomed.add(info.instance);
- updates.add(instance);
- TServerInfo tServerInfo = new TServerInfo(instance, new TServerConnection(client));
- current.put(zPath, tServerInfo);
- currentInstances.put(info.instance, tServerInfo);
- }
- }
- }
-
- @Override
- public void process(WatchedEvent event) {
-
- // its important that these event are propagated by ZooCache, because this ensures when reading zoocache that is has already processed the event and cleared
- // relevant nodes before code below reads from zoocache
-
- if (event.getPath() != null) {
- if (event.getPath().endsWith(Constants.ZTSERVERS)) {
- scanServers();
- } else if (event.getPath().contains(Constants.ZTSERVERS)) {
- int pos = event.getPath().lastIndexOf('/');
-
- // do only if ZTSERVER is parent
- if (pos >= 0 && event.getPath().substring(0, pos).endsWith(Constants.ZTSERVERS)) {
-
- String server = event.getPath().substring(pos + 1);
-
- final Set<TServerInstance> updates = new HashSet<TServerInstance>();
- final Set<TServerInstance> doomed = new HashSet<TServerInstance>();
-
- final String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
-
- try {
- checkServer(updates, doomed, path, server);
- if (!doomed.isEmpty() || !updates.isEmpty())
- this.cback.update(this, doomed, updates);
- } catch (Exception ex) {
- log.error(ex, ex);
- }
- }
- }
- }
- }
-
- public synchronized TServerConnection getConnection(TServerInstance server) throws TException {
- if (server == null)
- return null;
- TServerInfo tServerInfo = currentInstances.get(server);
- if (tServerInfo == null)
- return null;
- return tServerInfo.connection;
- }
-
- public synchronized Set<TServerInstance> getCurrentServers() {
- return new HashSet<TServerInstance>(currentInstances.keySet());
- }
-
- public synchronized int size() {
- return current.size();
- }
-
- public synchronized TServerInstance find(String tabletServer) {
- InetSocketAddress addr = AddressUtil.parseAddress(tabletServer);
- for (Entry<String,TServerInfo> entry : current.entrySet()) {
- if (entry.getValue().instance.getLocation().equals(addr))
- return entry.getValue().instance;
- }
- return null;
- }
-
- public synchronized void remove(TServerInstance server) {
- String zPath = null;
- for (Entry<String,TServerInfo> entry : current.entrySet()) {
- if (entry.getValue().instance.equals(server)) {
- zPath = entry.getKey();
- break;
- }
- }
- if (zPath == null)
- return;
- current.remove(zPath);
- currentInstances.remove(server);
-
- log.info("Removing zookeeper lock for " + server);
- String fullpath = ZooUtil.getRoot(instance) + Constants.ZTSERVERS + "/" + zPath;
- try {
- ZooReaderWriter.getRetryingInstance().recursiveDelete(fullpath, SKIP);
- } catch (Exception e) {
- String msg = "error removing tablet server lock";
- log.fatal(msg, e);
- Halt.halt(msg, -1);
- }
- getZooCache().clear(fullpath);
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/Assignment.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/Assignment.java b/server/base/src/main/java/org/apache/accumulo/master/state/Assignment.java
deleted file mode 100644
index efda721..0000000
--- a/server/base/src/main/java/org/apache/accumulo/master/state/Assignment.java
+++ /dev/null
@@ -1,30 +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.master.state;
-
-import org.apache.accumulo.core.data.KeyExtent;
-import org.apache.accumulo.master.state.TServerInstance;
-
-public class Assignment {
- public KeyExtent tablet;
- public TServerInstance server;
-
- public Assignment(KeyExtent tablet, TServerInstance server) {
- this.tablet = tablet;
- this.server = server;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/CurrentState.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/CurrentState.java b/server/base/src/main/java/org/apache/accumulo/master/state/CurrentState.java
deleted file mode 100644
index 8995fdb..0000000
--- a/server/base/src/main/java/org/apache/accumulo/master/state/CurrentState.java
+++ /dev/null
@@ -1,30 +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.master.state;
-
-import java.util.Collection;
-import java.util.Set;
-
-public interface CurrentState {
-
- Set<String> onlineTables();
-
- Set<TServerInstance> onlineTabletServers();
-
- Collection<MergeInfo> merges();
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/DeadServerList.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/DeadServerList.java b/server/base/src/main/java/org/apache/accumulo/master/state/DeadServerList.java
deleted file mode 100644
index 261f200..0000000
--- a/server/base/src/main/java/org/apache/accumulo/master/state/DeadServerList.java
+++ /dev/null
@@ -1,80 +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.master.state;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.accumulo.core.master.thrift.DeadServer;
-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.zookeeper.ZooReaderWriter;
-import org.apache.log4j.Logger;
-import org.apache.zookeeper.data.Stat;
-
-public class DeadServerList {
- private static final Logger log = Logger.getLogger(DeadServerList.class);
- private final String path;
-
- public DeadServerList(String path) {
- this.path = path;
- IZooReaderWriter zoo = ZooReaderWriter.getInstance();
- try {
- zoo.mkdirs(path);
- } catch (Exception ex) {
- log.error("Unable to make parent directories of " + path, ex);
- }
- }
-
- public List<DeadServer> getList() {
- List<DeadServer> result = new ArrayList<DeadServer>();
- IZooReaderWriter zoo = ZooReaderWriter.getInstance();
- try {
- List<String> children = zoo.getChildren(path);
- if (children != null) {
- for (String child : children) {
- Stat stat = new Stat();
- byte[] data = zoo.getData(path + "/" + child, stat);
- DeadServer server = new DeadServer(child, stat.getMtime(), new String(data));
- result.add(server);
- }
- }
- } catch (Exception ex) {
- log.error(ex, ex);
- }
- return result;
- }
-
- public void delete(String server) {
- IZooReaderWriter zoo = ZooReaderWriter.getInstance();
- try {
- zoo.recursiveDelete(path + "/" + server, NodeMissingPolicy.SKIP);
- } catch (Exception ex) {
- log.error(ex, ex);
- }
- }
-
- public void post(String server, String cause) {
- IZooReaderWriter zoo = ZooReaderWriter.getInstance();
- try {
- zoo.putPersistentData(path + "/" + server, cause.getBytes(), NodeExistsPolicy.SKIP);
- } catch (Exception ex) {
- log.error(ex, ex);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/DistributedStore.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/DistributedStore.java b/server/base/src/main/java/org/apache/accumulo/master/state/DistributedStore.java
deleted file mode 100644
index 786f342..0000000
--- a/server/base/src/main/java/org/apache/accumulo/master/state/DistributedStore.java
+++ /dev/null
@@ -1,34 +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.master.state;
-
-import java.util.List;
-
-/*
- * An abstract version of ZooKeeper that we can write tests against.
- */
-public interface DistributedStore {
-
- public List<String> getChildren(String path) throws DistributedStoreException;
-
- public byte[] get(String path) throws DistributedStoreException;
-
- public void put(String path, byte[] bs) throws DistributedStoreException;
-
- public void remove(String path) throws DistributedStoreException;
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/DistributedStoreException.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/DistributedStoreException.java b/server/base/src/main/java/org/apache/accumulo/master/state/DistributedStoreException.java
deleted file mode 100644
index 42652f8..0000000
--- a/server/base/src/main/java/org/apache/accumulo/master/state/DistributedStoreException.java
+++ /dev/null
@@ -1,34 +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.master.state;
-
-public class DistributedStoreException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public DistributedStoreException(String why) {
- super(why);
- }
-
- public DistributedStoreException(Exception cause) {
- super(cause);
- }
-
- public DistributedStoreException(String why, Exception cause) {
- super(why, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/MergeInfo.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/MergeInfo.java b/server/base/src/main/java/org/apache/accumulo/master/state/MergeInfo.java
deleted file mode 100644
index 056836e..0000000
--- a/server/base/src/main/java/org/apache/accumulo/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.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/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/MergeState.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/MergeState.java b/server/base/src/main/java/org/apache/accumulo/master/state/MergeState.java
deleted file mode 100644
index eb53c3a..0000000
--- a/server/base/src/main/java/org/apache/accumulo/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.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/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/MetaDataStateStore.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/MetaDataStateStore.java b/server/base/src/main/java/org/apache/accumulo/master/state/MetaDataStateStore.java
deleted file mode 100644
index 6108e10..0000000
--- a/server/base/src/main/java/org/apache/accumulo/master/state/MetaDataStateStore.java
+++ /dev/null
@@ -1,160 +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.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.master.state.CurrentState;
-import org.apache.accumulo.master.state.MetaDataTableScanner;
-import org.apache.accumulo.master.state.TabletLocationState;
-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/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/MetaDataTableScanner.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/MetaDataTableScanner.java b/server/base/src/main/java/org/apache/accumulo/master/state/MetaDataTableScanner.java
deleted file mode 100644
index a181325..0000000
--- a/server/base/src/main/java/org/apache/accumulo/master/state/MetaDataTableScanner.java
+++ /dev/null
@@ -1,196 +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.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.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;
- 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) {
- 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/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/RootTabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/RootTabletStateStore.java b/server/base/src/main/java/org/apache/accumulo/master/state/RootTabletStateStore.java
deleted file mode 100644
index b7071fe..0000000
--- a/server/base/src/main/java/org/apache/accumulo/master/state/RootTabletStateStore.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.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;
-import org.apache.accumulo.master.state.CurrentState;
-import org.apache.accumulo.master.state.MetaDataTableScanner;
-import org.apache.accumulo.master.state.TabletLocationState;
-
-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 "Non-Root Metadata Tablets";
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/TServerInstance.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/TServerInstance.java b/server/base/src/main/java/org/apache/accumulo/master/state/TServerInstance.java
deleted file mode 100644
index f9c054a..0000000
--- a/server/base/src/main/java/org/apache/accumulo/master/state/TServerInstance.java
+++ /dev/null
@@ -1,127 +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.master.state;
-
-import java.io.Serializable;
-import java.net.InetSocketAddress;
-
-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;
-
-/**
- * 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 InetSocketAddress location;
- private String session;
- private String cachedStringRepresentation;
-
- public TServerInstance(InetSocketAddress address, String session) {
- this.location = address;
- this.session = session;
- this.cachedStringRepresentation = hostPort() + "[" + session + "]";
- }
-
- public TServerInstance(InetSocketAddress 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().getAddress().getHostAddress();
- }
-
- public String hostPort() {
- return org.apache.accumulo.core.util.AddressUtil.toString(getLocation());
- }
-
- public Text asColumnQualifier() {
- return new Text(this.getSession());
- }
-
- public Value asMutationValue() {
- return new Value(org.apache.accumulo.core.util.AddressUtil.toString(getLocation()).getBytes());
- }
-
- public InetSocketAddress getLocation() {
- return location;
- }
-
- public String getSession() {
- return session;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/TabletLocationState.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/TabletLocationState.java b/server/base/src/main/java/org/apache/accumulo/master/state/TabletLocationState.java
deleted file mode 100644
index 0a95c49..0000000
--- a/server/base/src/main/java/org/apache/accumulo/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.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/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/TabletServerState.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/TabletServerState.java b/server/base/src/main/java/org/apache/accumulo/master/state/TabletServerState.java
deleted file mode 100644
index 41a54f3..0000000
--- a/server/base/src/main/java/org/apache/accumulo/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.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/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/TabletState.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/TabletState.java b/server/base/src/main/java/org/apache/accumulo/master/state/TabletState.java
deleted file mode 100644
index 2057a0e..0000000
--- a/server/base/src/main/java/org/apache/accumulo/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.master.state;
-
-public enum TabletState {
- UNASSIGNED, ASSIGNED, HOSTED, ASSIGNED_TO_DEAD_SERVER
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a10587ed/server/base/src/main/java/org/apache/accumulo/master/state/TabletStateChangeIterator.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/master/state/TabletStateChangeIterator.java b/server/base/src/main/java/org/apache/accumulo/master/state/TabletStateChangeIterator.java
deleted file mode 100644
index cd87c1e..0000000
--- a/server/base/src/main/java/org/apache/accumulo/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.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.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);
- }
-
-}