ctubbsii commented on a change in pull request #1584: Moved ThriftClientHandler out of TabletServer for #1581 URL: https://github.com/apache/accumulo/pull/1584#discussion_r406554802
########## File path: server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftClientHandler.java ########## @@ -0,0 +1,1812 @@ +/* + * 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.tserver; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedMap; +import java.util.SortedSet; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.apache.accumulo.core.Constants; +import org.apache.accumulo.core.client.AccumuloSecurityException; +import org.apache.accumulo.core.client.Durability; +import org.apache.accumulo.core.client.SampleNotPresentException; +import org.apache.accumulo.core.client.TableNotFoundException; +import org.apache.accumulo.core.clientImpl.CompressedIterators; +import org.apache.accumulo.core.clientImpl.DurabilityImpl; +import org.apache.accumulo.core.clientImpl.Tables; +import org.apache.accumulo.core.clientImpl.TabletType; +import org.apache.accumulo.core.clientImpl.Translator; +import org.apache.accumulo.core.clientImpl.Translator.TKeyExtentTranslator; +import org.apache.accumulo.core.clientImpl.Translator.TRangeTranslator; +import org.apache.accumulo.core.clientImpl.Translators; +import org.apache.accumulo.core.clientImpl.thrift.SecurityErrorCode; +import org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType; +import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException; +import org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException; +import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.data.Column; +import org.apache.accumulo.core.data.ConstraintViolationSummary; +import org.apache.accumulo.core.data.Key; +import org.apache.accumulo.core.data.Mutation; +import org.apache.accumulo.core.data.NamespaceId; +import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.TableId; +import org.apache.accumulo.core.dataImpl.KeyExtent; +import org.apache.accumulo.core.dataImpl.thrift.InitialMultiScan; +import org.apache.accumulo.core.dataImpl.thrift.InitialScan; +import org.apache.accumulo.core.dataImpl.thrift.IterInfo; +import org.apache.accumulo.core.dataImpl.thrift.MapFileInfo; +import org.apache.accumulo.core.dataImpl.thrift.MultiScanResult; +import org.apache.accumulo.core.dataImpl.thrift.ScanResult; +import org.apache.accumulo.core.dataImpl.thrift.TCMResult; +import org.apache.accumulo.core.dataImpl.thrift.TCMStatus; +import org.apache.accumulo.core.dataImpl.thrift.TColumn; +import org.apache.accumulo.core.dataImpl.thrift.TConditionalMutation; +import org.apache.accumulo.core.dataImpl.thrift.TConditionalSession; +import org.apache.accumulo.core.dataImpl.thrift.TKeyExtent; +import org.apache.accumulo.core.dataImpl.thrift.TKeyValue; +import org.apache.accumulo.core.dataImpl.thrift.TMutation; +import org.apache.accumulo.core.dataImpl.thrift.TRange; +import org.apache.accumulo.core.dataImpl.thrift.TRowRange; +import org.apache.accumulo.core.dataImpl.thrift.TSummaries; +import org.apache.accumulo.core.dataImpl.thrift.TSummaryRequest; +import org.apache.accumulo.core.dataImpl.thrift.UpdateErrors; +import org.apache.accumulo.core.iterators.IterationInterruptedException; +import org.apache.accumulo.core.logging.TabletLogger; +import org.apache.accumulo.core.master.thrift.TabletServerStatus; +import org.apache.accumulo.core.metadata.MetadataTable; +import org.apache.accumulo.core.metadata.RootTable; +import org.apache.accumulo.core.metadata.TabletFile; +import org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl; +import org.apache.accumulo.core.security.Authorizations; +import org.apache.accumulo.core.securityImpl.thrift.TCredentials; +import org.apache.accumulo.core.spi.cache.BlockCache; +import org.apache.accumulo.core.spi.scan.ScanDispatcher; +import org.apache.accumulo.core.summary.Gatherer; +import org.apache.accumulo.core.summary.Gatherer.FileSystemResolver; +import org.apache.accumulo.core.summary.SummaryCollection; +import org.apache.accumulo.core.tabletserver.thrift.ActiveCompaction; +import org.apache.accumulo.core.tabletserver.thrift.ActiveScan; +import org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException; +import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException; +import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException; +import org.apache.accumulo.core.tabletserver.thrift.TDurability; +import org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException; +import org.apache.accumulo.core.tabletserver.thrift.TSamplerConfiguration; +import org.apache.accumulo.core.tabletserver.thrift.TUnloadTabletGoal; +import org.apache.accumulo.core.tabletserver.thrift.TabletClientService; +import org.apache.accumulo.core.tabletserver.thrift.TabletStats; +import org.apache.accumulo.core.trace.thrift.TInfo; +import org.apache.accumulo.core.util.ByteBufferUtil; +import org.apache.accumulo.core.util.Daemon; +import org.apache.accumulo.core.util.Pair; +import org.apache.accumulo.fate.util.LoggingRunnable; +import org.apache.accumulo.fate.zookeeper.ZooLock; +import org.apache.accumulo.fate.zookeeper.ZooUtil; +import org.apache.accumulo.server.client.ClientServiceHandler; +import org.apache.accumulo.server.conf.TableConfiguration; +import org.apache.accumulo.server.data.ServerMutation; +import org.apache.accumulo.server.fs.VolumeManager; +import org.apache.accumulo.server.master.tableOps.UserCompactionConfig; +import org.apache.accumulo.server.rpc.TServerUtils; +import org.apache.accumulo.server.security.SecurityOperation; +import org.apache.accumulo.server.util.Halt; +import org.apache.accumulo.server.zookeeper.TransactionWatcher; +import org.apache.accumulo.tserver.ConditionCheckerContext.ConditionChecker; +import org.apache.accumulo.tserver.RowLocks.RowLock; +import org.apache.accumulo.tserver.data.ServerConditionalMutation; +import org.apache.accumulo.tserver.log.TabletServerLogger; +import org.apache.accumulo.tserver.metrics.TabletServerScanMetrics; +import org.apache.accumulo.tserver.metrics.TabletServerUpdateMetrics; +import org.apache.accumulo.tserver.scan.LookupTask; +import org.apache.accumulo.tserver.scan.NextBatchTask; +import org.apache.accumulo.tserver.scan.ScanParameters; +import org.apache.accumulo.tserver.session.ConditionalSession; +import org.apache.accumulo.tserver.session.MultiScanSession; +import org.apache.accumulo.tserver.session.SessionManager; +import org.apache.accumulo.tserver.session.SingleScanSession; +import org.apache.accumulo.tserver.session.SummarySession; +import org.apache.accumulo.tserver.session.UpdateSession; +import org.apache.accumulo.tserver.tablet.CommitSession; +import org.apache.accumulo.tserver.tablet.CompactionInfo; +import org.apache.accumulo.tserver.tablet.Compactor; +import org.apache.accumulo.tserver.tablet.KVEntry; +import org.apache.accumulo.tserver.tablet.PreparedMutations; +import org.apache.accumulo.tserver.tablet.ScanBatch; +import org.apache.accumulo.tserver.tablet.Tablet; +import org.apache.accumulo.tserver.tablet.TabletClosedException; +import org.apache.hadoop.fs.FSError; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.Text; +import org.apache.htrace.Trace; +import org.apache.htrace.TraceScope; +import org.apache.thrift.TException; +import org.apache.zookeeper.KeeperException.NoNodeException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.cache.Cache; +import com.google.common.collect.Collections2; + +public class ThriftClientHandler extends ClientServiceHandler implements TabletClientService.Iface { + + private static final Logger log = LoggerFactory.getLogger(ThriftClientHandler.class); + private static final long MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS = 1000; + private static final long RECENTLY_SPLIT_MILLIES = 60 * 1000; + private final TabletServer server; + private final WriteTracker writeTracker = new WriteTracker(); + private final RowLocks rowLocks = new RowLocks(); + private final TransactionWatcher watcher; + private final VolumeManager fs; + private final SecurityOperation security; + private final SessionManager sessionManager; + private final TabletServerUpdateMetrics updateMetrics; + private final TabletServerScanMetrics scanMetrics; + private final TabletServerLogger logger; + + public ThriftClientHandler(TabletServer server) { + super(server.getContext(), server.getWatcher(), server.getFileSystem()); + this.server = server; + this.watcher = server.getWatcher(); Review comment: As stated earlier, you can get the stuff from the context and the super class: ```suggestion super(server.getContext(), new TransactionWatcher(server.getContext()), server.getContext().getVolumeManager()); this.server = server; this.watcher = transactionWatcher; ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
