[ 
https://issues.apache.org/jira/browse/GEODE-8078?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17107780#comment-17107780
 ] 

ASF GitHub Bot commented on GEODE-8078:
---------------------------------------

jinmeiliao commented on a change in pull request #5111:
URL: https://github.com/apache/geode/pull/5111#discussion_r425481311



##########
File path: 
geode-web-management/src/distributedTest/java/org/apache/geode/management/client/GetStartingMemberTest.java
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.geode.management.client;
+
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.context.WebApplicationContext;
+
+import org.apache.geode.management.api.ClusterManagementException;
+import org.apache.geode.management.api.ClusterManagementGetResult;
+import org.apache.geode.management.api.ClusterManagementService;
+import 
org.apache.geode.management.api.RestTemplateClusterManagementServiceTransport;
+import org.apache.geode.management.configuration.Member;
+import org.apache.geode.management.internal.rest.LocatorWebContext;
+import org.apache.geode.management.internal.rest.PlainLocatorContextLoader;
+import org.apache.geode.management.runtime.MemberInformation;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.junit.rules.ConcurrencyRule;
+
+@RunWith(SpringRunner.class)
+@ContextConfiguration(locations = 
{"classpath*:WEB-INF/management-servlet.xml"},
+    loader = PlainLocatorContextLoader.class)
+@WebAppConfiguration
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
+public class GetStartingMemberTest {
+
+  @Autowired
+  private WebApplicationContext webApplicationContext;
+
+  @Rule
+  public ClusterStartupRule cluster = new ClusterStartupRule(1);
+
+  @Rule
+  public ConcurrencyRule concurrency = new ConcurrencyRule();
+
+  private ClusterManagementService client;
+  private LocatorWebContext webContext;
+
+  @Before
+  public void before() {
+    cluster.setSkipLocalDistributedSystemCleanup(true);
+    webContext = new LocatorWebContext(webApplicationContext);
+    client = new ClusterManagementServiceBuilder().setTransport(
+        new RestTemplateClusterManagementServiceTransport(
+            new RestTemplate(webContext.getRequestFactory())))
+        .build();
+  }
+
+  @Test
+  public void getStartingMember() throws Exception {
+    Member server0 = new Member();
+    server0.setId("server-0");
+    concurrency.add(() -> cluster.startServerVM(0, 
webContext.getLocator().getPort()));
+    concurrency.add(() -> {
+      ClusterManagementGetResult<Member, MemberInformation> result = null;
+      while (result == null) {
+        try {
+          result = client.get(server0);
+        } catch (ClusterManagementException e) {
+          // this is expected for the first several tries
+        }
+      }
+      return result;
+    });
+    concurrency.executeInParallel();

Review comment:
       Great, thank you so much!




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


> Exceptions in locator logs when hitting members REST endpoint
> -------------------------------------------------------------
>
>                 Key: GEODE-8078
>                 URL: https://issues.apache.org/jira/browse/GEODE-8078
>             Project: Geode
>          Issue Type: Bug
>          Components: management
>            Reporter: Aaron Lindsey
>            Priority: Major
>              Labels: GeodeOperationAPI
>
> I'm seeing the following exceptions in locator logs when I try to hit the 
> REST endpoint /management/v1/members/\{id} before the member has finished 
> starting up. The reason I need to do this is because I have a program that is 
> polling that endpoint to wait until the member is online. Ideally these 
> errors would not show up in logs, but instead be reflected in the status code 
> of the REST response.
> {quote}[error 2020/04/06 22:05:59.086 UTC <qtp481947474-49> tid=0x31] class 
> org.apache.geode.cache.CacheClosedException cannot be cast to class 
> org.apache.geode.management.runtime.RuntimeInfo 
> (org.apache.geode.cache.CacheClosedException and 
> org.apache.geode.management.runtime.RuntimeInfo are in unnamed module of 
> loader 'app')
> java.lang.ClassCastException: class 
> org.apache.geode.cache.CacheClosedException cannot be cast to class 
> org.apache.geode.management.runtime.RuntimeInfo 
> (org.apache.geode.cache.CacheClosedException and 
> org.apache.geode.management.runtime.RuntimeInfo are in unnamed module of 
> loader 'app')
>         at 
> org.apache.geode.management.internal.api.LocatorClusterManagementService.list(LocatorClusterManagementService.java:417)
>         at 
> org.apache.geode.management.internal.api.LocatorClusterManagementService.get(LocatorClusterManagementService.java:434)
>         at 
> org.apache.geode.management.internal.rest.controllers.MemberManagementController.getMember(MemberManagementController.java:50)
>         at 
> org.apache.geode.management.internal.rest.controllers.MemberManagementController$$FastClassBySpringCGLIB$$3634e452.invoke(<generated>)
>         at 
> org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
>         at 
> org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769)
>         at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
>         at 
> org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
>         at 
> org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:69)
>         at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
>         at 
> org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
>         at 
> org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
>         at 
> org.apache.geode.management.internal.rest.controllers.MemberManagementController$$EnhancerBySpringCGLIB$$2893b195.getMember(<generated>)
>         at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>         at 
> org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
>         at 
> org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
>         at 
> org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
>         at 
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888)
>         at 
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
>         at 
> org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
>         at 
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
>         at 
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
>         at 
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
>         at 
> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
>         at 
> org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
>         at 
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:760)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1617)
>         at 
> org.apache.geode.management.internal.rest.ManagementLoggingFilter.doFilterInternal(ManagementLoggingFilter.java:44)
>         at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1604)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
>         at 
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
>         at 
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
>         at 
> org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
>         at 
> org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
>         at 
> org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
>         at 
> org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
>         at 
> org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
>         at 
> org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
>         at 
> org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92)
>         at 
> org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77)
>         at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334{quote}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to