You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2020/08/27 15:34:39 UTC

[GitHub] [knox] pzampino commented on a change in pull request #365: KNOX-2402 - Adding Gateway performance testing

pzampino commented on a change in pull request #365:
URL: https://github.com/apache/knox/pull/365#discussion_r478501003



##########
File path: gateway-performance-test/src/main/java/org/apache/knox/gateway/performance/test/knoxtoken/KnoxTokenCache.java
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.knox.gateway.performance.test.knoxtoken;
+
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+class KnoxTokenCache {
+  private static final int CAPACITY = 500;
+  private final Queue<String> knoxTokens = new ConcurrentLinkedQueue<>();
+
+  void saveKnoxToken(String knoxToken) {
+    cleanIfNecessary();
+    this.knoxTokens.offer(knoxToken);

Review comment:
       Is it acceptable for a token to NOT be saved here? Just wondering why you're using _offer_ instead of _add_.

##########
File path: gateway-performance-test/src/main/java/org/apache/knox/gateway/performance/test/PerformanceTestRunner.java
##########
@@ -0,0 +1,40 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.knox.gateway.performance.test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.knox.gateway.performance.test.reporting.GatewayMetricsReporter;
+
+public class PerformanceTestRunner {
+
+  public static void main(String[] args) throws Exception {
+    final PerformanceTestConfiguration configuration = new PerformanceTestConfiguration(args[0]);
+    final ResponseTimeCache responseTimeCache = new ResponseTimeCache();
+    final GatewayMetricsReporter metricsReporter = new GatewayMetricsReporter(configuration, responseTimeCache);
+    metricsReporter.start();
+    final List<PerformanceTestLifeCyleListener> lifeCyleListeners = Arrays.asList(metricsReporter);
+    for (PerformanceTestUseCase useCase : PerformanceTestUseCase.values()) {

Review comment:
       Could use ServiceLoader instead of a hard-coded enum to find PerformanceTestUseCase implementations.

##########
File path: gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenStateService.java
##########
@@ -154,17 +177,16 @@ public long getTokenExpiration(final String tokenId) throws UnknownTokenExceptio
 
   @Override
   public long getTokenExpiration(String tokenId, boolean validate) throws UnknownTokenException {
-    long expiration;
-
     if (validate) {
       validateToken(tokenId);
     }
 
+    long expiration = -1;
     synchronized (tokenExpirations) {
-      if (!tokenExpirations.containsKey(tokenId)) {
-        throw new UnknownTokenException(tokenId);
-      }
-      expiration = tokenExpirations.get(tokenId);
+      expiration = tokenExpirations.getOrDefault(tokenId, -1L);
+    }
+    if (expiration == -1) {

Review comment:
       This doesn't appear to be any different than the previous implementation. If this were a check for _expiration < 0_, I could see a difference. What is the reason for the change?

##########
File path: gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Ls.java
##########
@@ -41,6 +42,11 @@ public Request dir( String dir ) {
       return this;
     }
 
+    public Request knoxToken(String knoxToken) {

Review comment:
       Why not add Knox token support to KnoxSession?




----------------------------------------------------------------
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:
users@infra.apache.org