You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/04/20 17:47:06 UTC

[GitHub] [accumulo] dlmarion opened a new pull request, #2643: Separated tablet scan functions from TabletClientService into a new Thrift service

dlmarion opened a new pull request, #2643:
URL: https://github.com/apache/accumulo/pull/2643

   related to #2640


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] dlmarion commented on a diff in pull request #2643: Separated tablet scan functions from TabletClientService into a new Thrift service

Posted by GitBox <gi...@apache.org>.
dlmarion commented on code in PR #2643:
URL: https://github.com/apache/accumulo/pull/2643#discussion_r854549278


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftScanClientHandler.java:
##########
@@ -0,0 +1,531 @@
+/*
+ * 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.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.SampleNotPresentException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.clientImpl.TabletType;
+import org.apache.accumulo.core.clientImpl.thrift.SecurityErrorCode;
+import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Column;
+import org.apache.accumulo.core.data.Key;
+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.MultiScanResult;
+import org.apache.accumulo.core.dataImpl.thrift.ScanResult;
+import org.apache.accumulo.core.dataImpl.thrift.TColumn;
+import org.apache.accumulo.core.dataImpl.thrift.TKeyExtent;
+import org.apache.accumulo.core.dataImpl.thrift.TKeyValue;
+import org.apache.accumulo.core.dataImpl.thrift.TRange;
+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.scan.ScanDispatcher;
+import org.apache.accumulo.core.tabletserver.thrift.ActiveScan;
+import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException;
+import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException;
+import org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException;
+import org.apache.accumulo.core.tabletserver.thrift.TSamplerConfiguration;
+import org.apache.accumulo.core.tabletserver.thrift.TabletScanClientService;
+import org.apache.accumulo.core.trace.thrift.TInfo;
+import org.apache.accumulo.core.util.Halt;
+import org.apache.accumulo.fate.zookeeper.ServiceLock;
+import org.apache.accumulo.fate.zookeeper.ZooUtil;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.fs.TooManyFilesException;
+import org.apache.accumulo.server.rpc.TServerUtils;
+import org.apache.accumulo.server.security.AuditedSecurityOperation;
+import org.apache.accumulo.server.security.SecurityOperation;
+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.MultiScanSession;
+import org.apache.accumulo.tserver.session.SingleScanSession;
+import org.apache.accumulo.tserver.tablet.KVEntry;
+import org.apache.accumulo.tserver.tablet.ScanBatch;
+import org.apache.accumulo.tserver.tablet.Tablet;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Collections2;
+
+public class ThriftScanClientHandler implements TabletScanClientService.Iface {
+
+  private static final Logger log = LoggerFactory.getLogger(ThriftScanClientHandler.class);
+
+  private final TabletServer server;
+  protected final ServerContext context;
+  protected final SecurityOperation security;
+  private final WriteTracker writeTracker;
+  private final long MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS;
+
+  public ThriftScanClientHandler(TabletServer server, WriteTracker writeTracker) {
+    this.server = server;
+    this.context = server.getContext();
+    this.writeTracker = writeTracker;
+    this.security = AuditedSecurityOperation.getInstance(context);
+    MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS = server.getContext().getConfiguration()
+        .getTimeInMillis(Property.TSERV_SCAN_RESULTS_MAX_TIMEOUT);
+  }
+
+  private void checkPermission(TCredentials credentials, String lock, final String request)

Review Comment:
   Addressed in d4b1a76



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] dlmarion commented on a diff in pull request #2643: Separated tablet scan functions from TabletClientService into a new Thrift service

Posted by GitBox <gi...@apache.org>.
dlmarion commented on code in PR #2643:
URL: https://github.com/apache/accumulo/pull/2643#discussion_r854518218


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftScanClientHandler.java:
##########
@@ -0,0 +1,531 @@
+/*
+ * 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.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.SampleNotPresentException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.clientImpl.TabletType;
+import org.apache.accumulo.core.clientImpl.thrift.SecurityErrorCode;
+import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Column;
+import org.apache.accumulo.core.data.Key;
+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.MultiScanResult;
+import org.apache.accumulo.core.dataImpl.thrift.ScanResult;
+import org.apache.accumulo.core.dataImpl.thrift.TColumn;
+import org.apache.accumulo.core.dataImpl.thrift.TKeyExtent;
+import org.apache.accumulo.core.dataImpl.thrift.TKeyValue;
+import org.apache.accumulo.core.dataImpl.thrift.TRange;
+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.scan.ScanDispatcher;
+import org.apache.accumulo.core.tabletserver.thrift.ActiveScan;
+import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException;
+import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException;
+import org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException;
+import org.apache.accumulo.core.tabletserver.thrift.TSamplerConfiguration;
+import org.apache.accumulo.core.tabletserver.thrift.TabletScanClientService;
+import org.apache.accumulo.core.trace.thrift.TInfo;
+import org.apache.accumulo.core.util.Halt;
+import org.apache.accumulo.fate.zookeeper.ServiceLock;
+import org.apache.accumulo.fate.zookeeper.ZooUtil;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.fs.TooManyFilesException;
+import org.apache.accumulo.server.rpc.TServerUtils;
+import org.apache.accumulo.server.security.AuditedSecurityOperation;
+import org.apache.accumulo.server.security.SecurityOperation;
+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.MultiScanSession;
+import org.apache.accumulo.tserver.session.SingleScanSession;
+import org.apache.accumulo.tserver.tablet.KVEntry;
+import org.apache.accumulo.tserver.tablet.ScanBatch;
+import org.apache.accumulo.tserver.tablet.Tablet;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Collections2;
+
+public class ThriftScanClientHandler implements TabletScanClientService.Iface {
+
+  private static final Logger log = LoggerFactory.getLogger(ThriftScanClientHandler.class);
+
+  private final TabletServer server;
+  protected final ServerContext context;
+  protected final SecurityOperation security;
+  private final WriteTracker writeTracker;
+  private final long MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS;
+
+  public ThriftScanClientHandler(TabletServer server, WriteTracker writeTracker) {
+    this.server = server;
+    this.context = server.getContext();
+    this.writeTracker = writeTracker;
+    this.security = AuditedSecurityOperation.getInstance(context);
+    MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS = server.getContext().getConfiguration()
+        .getTimeInMillis(Property.TSERV_SCAN_RESULTS_MAX_TIMEOUT);
+  }
+
+  private void checkPermission(TCredentials credentials, String lock, final String request)
+      throws ThriftSecurityException {
+    try {
+      log.trace("Got {} message from user: {}", request, credentials.getPrincipal());
+      if (!security.canPerformSystemActions(credentials)) {
+        log.warn("Got {} message from user: {}", request, credentials.getPrincipal());
+        throw new ThriftSecurityException(credentials.getPrincipal(),
+            SecurityErrorCode.PERMISSION_DENIED);
+      }
+    } catch (ThriftSecurityException e) {
+      log.warn("Got {} message from unauthenticatable user: {}", request, e.getUser());
+      if (context.getCredentials().getToken().getClass().getName()
+          .equals(credentials.getTokenClassName())) {
+        log.error("Got message from a service with a mismatched configuration."
+            + " Please ensure a compatible configuration.", e);
+      }
+      throw e;
+    }
+
+    if (server.getLock() == null || !server.getLock().wasLockAcquired()) {
+      log.debug("Got {} message before my lock was acquired, ignoring...", request);
+      throw new RuntimeException("Lock not acquired");
+    }
+
+    if (server.getLock() != null && server.getLock().wasLockAcquired()
+        && !server.getLock().isLocked()) {
+      Halt.halt(1, () -> {
+        log.info("Tablet server no longer holds lock during checkPermission() : {}, exiting",
+            request);
+        server.gcLogger.logGCInfo(server.getConfiguration());
+      });
+    }
+
+    if (lock != null) {
+      ZooUtil.LockID lid =
+          new ZooUtil.LockID(context.getZooKeeperRoot() + Constants.ZMANAGER_LOCK, lock);
+
+      try {
+        if (!ServiceLock.isLockHeld(server.managerLockCache, lid)) {
+          // maybe the cache is out of date and a new manager holds the
+          // lock?
+          server.managerLockCache.clear();
+          if (!ServiceLock.isLockHeld(server.managerLockCache, lid)) {
+            log.warn("Got {} message from a manager that does not hold the current lock {}",
+                request, lock);
+            throw new RuntimeException("bad manager lock");
+          }
+        }
+      } catch (Exception e) {
+        throw new RuntimeException("bad manager lock", e);
+      }
+    }
+  }
+
+  private NamespaceId getNamespaceId(TCredentials credentials, TableId tableId)
+      throws ThriftSecurityException {
+    try {
+      return server.getContext().getNamespaceId(tableId);
+    } catch (TableNotFoundException e1) {
+      throw new ThriftSecurityException(credentials.getPrincipal(),
+          SecurityErrorCode.TABLE_DOESNT_EXIST);
+    }
+  }
+
+  private ScanDispatcher getScanDispatcher(KeyExtent extent) {
+    if (extent.isRootTablet() || extent.isMeta()) {
+      // dispatcher is only for user tables
+      return null;
+    }
+
+    return context.getTableConfiguration(extent.tableId()).getScanDispatcher();
+  }
+
+  @Override
+  public InitialScan startScan(TInfo tinfo, TCredentials credentials, TKeyExtent textent,

Review Comment:
   Should be an exact copy, there were no changes to the Thrift method signatures, just moving them. IIRC, I copied the code and pasted it into a new class.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] DomGarguilo commented on pull request #2643: Separated tablet scan functions from TabletClientService into a new Thrift service

Posted by GitBox <gi...@apache.org>.
DomGarguilo commented on PR #2643:
URL: https://github.com/apache/accumulo/pull/2643#issuecomment-1104379909

   > SSLIT.adminStop timed out after 3 minutes 
   
   The timeouts for this IT were recently adjusted (see #2631) so it might just be that the timeout needs to be increased for this test


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] dlmarion commented on a diff in pull request #2643: Separated tablet scan functions from TabletClientService into a new Thrift service

Posted by GitBox <gi...@apache.org>.
dlmarion commented on code in PR #2643:
URL: https://github.com/apache/accumulo/pull/2643#discussion_r854517587


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftScanClientHandler.java:
##########
@@ -0,0 +1,531 @@
+/*
+ * 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.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.SampleNotPresentException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.clientImpl.TabletType;
+import org.apache.accumulo.core.clientImpl.thrift.SecurityErrorCode;
+import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Column;
+import org.apache.accumulo.core.data.Key;
+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.MultiScanResult;
+import org.apache.accumulo.core.dataImpl.thrift.ScanResult;
+import org.apache.accumulo.core.dataImpl.thrift.TColumn;
+import org.apache.accumulo.core.dataImpl.thrift.TKeyExtent;
+import org.apache.accumulo.core.dataImpl.thrift.TKeyValue;
+import org.apache.accumulo.core.dataImpl.thrift.TRange;
+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.scan.ScanDispatcher;
+import org.apache.accumulo.core.tabletserver.thrift.ActiveScan;
+import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException;
+import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException;
+import org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException;
+import org.apache.accumulo.core.tabletserver.thrift.TSamplerConfiguration;
+import org.apache.accumulo.core.tabletserver.thrift.TabletScanClientService;
+import org.apache.accumulo.core.trace.thrift.TInfo;
+import org.apache.accumulo.core.util.Halt;
+import org.apache.accumulo.fate.zookeeper.ServiceLock;
+import org.apache.accumulo.fate.zookeeper.ZooUtil;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.fs.TooManyFilesException;
+import org.apache.accumulo.server.rpc.TServerUtils;
+import org.apache.accumulo.server.security.AuditedSecurityOperation;
+import org.apache.accumulo.server.security.SecurityOperation;
+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.MultiScanSession;
+import org.apache.accumulo.tserver.session.SingleScanSession;
+import org.apache.accumulo.tserver.tablet.KVEntry;
+import org.apache.accumulo.tserver.tablet.ScanBatch;
+import org.apache.accumulo.tserver.tablet.Tablet;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Collections2;
+
+public class ThriftScanClientHandler implements TabletScanClientService.Iface {
+
+  private static final Logger log = LoggerFactory.getLogger(ThriftScanClientHandler.class);
+
+  private final TabletServer server;
+  protected final ServerContext context;
+  protected final SecurityOperation security;
+  private final WriteTracker writeTracker;
+  private final long MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS;
+
+  public ThriftScanClientHandler(TabletServer server, WriteTracker writeTracker) {
+    this.server = server;
+    this.context = server.getContext();
+    this.writeTracker = writeTracker;
+    this.security = AuditedSecurityOperation.getInstance(context);
+    MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS = server.getContext().getConfiguration()
+        .getTimeInMillis(Property.TSERV_SCAN_RESULTS_MAX_TIMEOUT);
+  }
+
+  private void checkPermission(TCredentials credentials, String lock, final String request)

Review Comment:
   Yes, should be a copy. I can consolidate.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] keith-turner commented on a diff in pull request #2643: Separated tablet scan functions from TabletClientService into a new Thrift service

Posted by GitBox <gi...@apache.org>.
keith-turner commented on code in PR #2643:
URL: https://github.com/apache/accumulo/pull/2643#discussion_r854502308


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftScanClientHandler.java:
##########
@@ -0,0 +1,531 @@
+/*
+ * 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.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.SampleNotPresentException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.clientImpl.TabletType;
+import org.apache.accumulo.core.clientImpl.thrift.SecurityErrorCode;
+import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Column;
+import org.apache.accumulo.core.data.Key;
+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.MultiScanResult;
+import org.apache.accumulo.core.dataImpl.thrift.ScanResult;
+import org.apache.accumulo.core.dataImpl.thrift.TColumn;
+import org.apache.accumulo.core.dataImpl.thrift.TKeyExtent;
+import org.apache.accumulo.core.dataImpl.thrift.TKeyValue;
+import org.apache.accumulo.core.dataImpl.thrift.TRange;
+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.scan.ScanDispatcher;
+import org.apache.accumulo.core.tabletserver.thrift.ActiveScan;
+import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException;
+import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException;
+import org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException;
+import org.apache.accumulo.core.tabletserver.thrift.TSamplerConfiguration;
+import org.apache.accumulo.core.tabletserver.thrift.TabletScanClientService;
+import org.apache.accumulo.core.trace.thrift.TInfo;
+import org.apache.accumulo.core.util.Halt;
+import org.apache.accumulo.fate.zookeeper.ServiceLock;
+import org.apache.accumulo.fate.zookeeper.ZooUtil;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.fs.TooManyFilesException;
+import org.apache.accumulo.server.rpc.TServerUtils;
+import org.apache.accumulo.server.security.AuditedSecurityOperation;
+import org.apache.accumulo.server.security.SecurityOperation;
+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.MultiScanSession;
+import org.apache.accumulo.tserver.session.SingleScanSession;
+import org.apache.accumulo.tserver.tablet.KVEntry;
+import org.apache.accumulo.tserver.tablet.ScanBatch;
+import org.apache.accumulo.tserver.tablet.Tablet;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Collections2;
+
+public class ThriftScanClientHandler implements TabletScanClientService.Iface {
+
+  private static final Logger log = LoggerFactory.getLogger(ThriftScanClientHandler.class);
+
+  private final TabletServer server;
+  protected final ServerContext context;
+  protected final SecurityOperation security;
+  private final WriteTracker writeTracker;
+  private final long MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS;
+
+  public ThriftScanClientHandler(TabletServer server, WriteTracker writeTracker) {
+    this.server = server;
+    this.context = server.getContext();
+    this.writeTracker = writeTracker;
+    this.security = AuditedSecurityOperation.getInstance(context);
+    MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS = server.getContext().getConfiguration()
+        .getTimeInMillis(Property.TSERV_SCAN_RESULTS_MAX_TIMEOUT);
+  }
+
+  private void checkPermission(TCredentials credentials, String lock, final String request)

Review Comment:
   Is this method identical to what is in TabletClientHandler?  If so may be good to share the code.  Maybe once class could have a static method that they both call.



##########
server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftScanClientHandler.java:
##########
@@ -0,0 +1,531 @@
+/*
+ * 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.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.SampleNotPresentException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.clientImpl.TabletType;
+import org.apache.accumulo.core.clientImpl.thrift.SecurityErrorCode;
+import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Column;
+import org.apache.accumulo.core.data.Key;
+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.MultiScanResult;
+import org.apache.accumulo.core.dataImpl.thrift.ScanResult;
+import org.apache.accumulo.core.dataImpl.thrift.TColumn;
+import org.apache.accumulo.core.dataImpl.thrift.TKeyExtent;
+import org.apache.accumulo.core.dataImpl.thrift.TKeyValue;
+import org.apache.accumulo.core.dataImpl.thrift.TRange;
+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.scan.ScanDispatcher;
+import org.apache.accumulo.core.tabletserver.thrift.ActiveScan;
+import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException;
+import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException;
+import org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException;
+import org.apache.accumulo.core.tabletserver.thrift.TSamplerConfiguration;
+import org.apache.accumulo.core.tabletserver.thrift.TabletScanClientService;
+import org.apache.accumulo.core.trace.thrift.TInfo;
+import org.apache.accumulo.core.util.Halt;
+import org.apache.accumulo.fate.zookeeper.ServiceLock;
+import org.apache.accumulo.fate.zookeeper.ZooUtil;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.fs.TooManyFilesException;
+import org.apache.accumulo.server.rpc.TServerUtils;
+import org.apache.accumulo.server.security.AuditedSecurityOperation;
+import org.apache.accumulo.server.security.SecurityOperation;
+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.MultiScanSession;
+import org.apache.accumulo.tserver.session.SingleScanSession;
+import org.apache.accumulo.tserver.tablet.KVEntry;
+import org.apache.accumulo.tserver.tablet.ScanBatch;
+import org.apache.accumulo.tserver.tablet.Tablet;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Collections2;
+
+public class ThriftScanClientHandler implements TabletScanClientService.Iface {
+
+  private static final Logger log = LoggerFactory.getLogger(ThriftScanClientHandler.class);
+
+  private final TabletServer server;
+  protected final ServerContext context;
+  protected final SecurityOperation security;
+  private final WriteTracker writeTracker;
+  private final long MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS;
+
+  public ThriftScanClientHandler(TabletServer server, WriteTracker writeTracker) {
+    this.server = server;
+    this.context = server.getContext();
+    this.writeTracker = writeTracker;
+    this.security = AuditedSecurityOperation.getInstance(context);
+    MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS = server.getContext().getConfiguration()
+        .getTimeInMillis(Property.TSERV_SCAN_RESULTS_MAX_TIMEOUT);
+  }
+
+  private void checkPermission(TCredentials credentials, String lock, final String request)
+      throws ThriftSecurityException {
+    try {
+      log.trace("Got {} message from user: {}", request, credentials.getPrincipal());
+      if (!security.canPerformSystemActions(credentials)) {
+        log.warn("Got {} message from user: {}", request, credentials.getPrincipal());
+        throw new ThriftSecurityException(credentials.getPrincipal(),
+            SecurityErrorCode.PERMISSION_DENIED);
+      }
+    } catch (ThriftSecurityException e) {
+      log.warn("Got {} message from unauthenticatable user: {}", request, e.getUser());
+      if (context.getCredentials().getToken().getClass().getName()
+          .equals(credentials.getTokenClassName())) {
+        log.error("Got message from a service with a mismatched configuration."
+            + " Please ensure a compatible configuration.", e);
+      }
+      throw e;
+    }
+
+    if (server.getLock() == null || !server.getLock().wasLockAcquired()) {
+      log.debug("Got {} message before my lock was acquired, ignoring...", request);
+      throw new RuntimeException("Lock not acquired");
+    }
+
+    if (server.getLock() != null && server.getLock().wasLockAcquired()
+        && !server.getLock().isLocked()) {
+      Halt.halt(1, () -> {
+        log.info("Tablet server no longer holds lock during checkPermission() : {}, exiting",
+            request);
+        server.gcLogger.logGCInfo(server.getConfiguration());
+      });
+    }
+
+    if (lock != null) {
+      ZooUtil.LockID lid =
+          new ZooUtil.LockID(context.getZooKeeperRoot() + Constants.ZMANAGER_LOCK, lock);
+
+      try {
+        if (!ServiceLock.isLockHeld(server.managerLockCache, lid)) {
+          // maybe the cache is out of date and a new manager holds the
+          // lock?
+          server.managerLockCache.clear();
+          if (!ServiceLock.isLockHeld(server.managerLockCache, lid)) {
+            log.warn("Got {} message from a manager that does not hold the current lock {}",
+                request, lock);
+            throw new RuntimeException("bad manager lock");
+          }
+        }
+      } catch (Exception e) {
+        throw new RuntimeException("bad manager lock", e);
+      }
+    }
+  }
+
+  private NamespaceId getNamespaceId(TCredentials credentials, TableId tableId)
+      throws ThriftSecurityException {
+    try {
+      return server.getContext().getNamespaceId(tableId);
+    } catch (TableNotFoundException e1) {
+      throw new ThriftSecurityException(credentials.getPrincipal(),
+          SecurityErrorCode.TABLE_DOESNT_EXIST);
+    }
+  }
+
+  private ScanDispatcher getScanDispatcher(KeyExtent extent) {
+    if (extent.isRootTablet() || extent.isMeta()) {
+      // dispatcher is only for user tables
+      return null;
+    }
+
+    return context.getTableConfiguration(extent.tableId()).getScanDispatcher();
+  }
+
+  @Override
+  public InitialScan startScan(TInfo tinfo, TCredentials credentials, TKeyExtent textent,

Review Comment:
   Were all of these overridden methods copied exactly from TabletClientHandler?  Wondering if there any changes to look at.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] dlmarion commented on pull request #2643: Separated tablet scan functions from TabletClientService into a new Thrift service

Posted by GitBox <gi...@apache.org>.
dlmarion commented on PR #2643:
URL: https://github.com/apache/accumulo/pull/2643#issuecomment-1104326241

   IT Test run had 2 failures. SSLIT.adminStop timed out after 3 minutes and LateLastContactIT timed out. All others passed at https://github.com/dlmarion/accumulo/runs/6099910179


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] dlmarion merged pull request #2643: Separated tablet scan functions from TabletClientService into a new Thrift service

Posted by GitBox <gi...@apache.org>.
dlmarion merged PR #2643:
URL: https://github.com/apache/accumulo/pull/2643


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org