Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Help in Using Cloudera API

avatar
Explorer

Hi All 

 

I am new cloudera .We are trying to use cloudera API to start and stop the cluster .

 

We are able to fetch the list of running services from the server using 

 

http://x.x.x.x:7180/api/v9/clusters/cluster%201/services

 

but when we run /api/v9/cluster%201/commands/stop it doesnt work .Detailed logs are given below .

 

We are logging as admin user so dont think that it is an authetication issue.

 

Any help would be appreciated .

 

Thanks in Advance

 

 

 

 

 

GET /api/v9/clusters/cluster%201/commands/stop
Encoding: UTF-8
Authentication: admin [AUTH_AUDITS, AUTH_BDR_ADMIN, AUTH_DASHBOARDS, AUTH_DECOMMISSION_HOST, AUTH_DECOMMISSION_OTHER, AUTH_FULL_ADMIN_CONFIG, AUTH_MAINTENANCE_MODE, AUTH_NAVIGATOR, AUTH_POWER_OPS, AUTH_SERVICE_CONFIG, AUTH_USERS_CONFIG, ROLE_ADMIN, ROLE_USER]
Headers:
Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8]
accept-encoding=[gzip, deflate, sdch]
Accept-Language=[en,en-GB;q=0.8]
Cache-Control=[max-age=0]
connection=[keep-alive]
Content-Type=[null]
Cookie=[CLOUDERA_MANAGER_SESSIONID=1ug76nnhd0hgh1l65yr9ne2ctx; __utmt=1; __utma=23390714.835512087.1425178810.1425882932.1425888028.13; __utmb=23390714.17.10.1425888028; __utmc=23390714; __utmz=23390714.1425178810.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)]
Host=[192.168.1.79:7180]
User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36]
2015-03-09 17:54:12,952 WARN 816231420@scm-web-41650:org.apache.cxf.jaxrs.utils.JAXRSUtils: No operation matching request path "/api/v9/clusters/cluster%201/commands/stop" is found on subresource, Relative Path: /cluster%201/commands/stop, HTTP Method: GET, ContentType: */*, Accept: text/html,application/xhtml+xml,image/webp,application/xml;q=0.9,*/*;q=0.8,. Please enable FINE/TRACE log level for more details.
2015-03-09 17:54:12,952 DEBUG 816231420@scm-web-41650:com.cloudera.api.ApiExceptionMapper: WebApplicationException caught in API invocation.
javax.ws.rs.ClientErrorException
at org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:490)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:236)
at com.cloudera.api.ApiInvoker.invoke(ApiInvoker.java:116)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:257)
at com.cloudera.api.ApiInvoker.invoke(ApiInvoker.java:116)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:168)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
at com.cloudera.enterprise.JavaMelodyFacade$MonitoringFilter.doFilter(JavaMelodyFacade.java:109)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at com.cloudera.api.ApiBasicAuthFilter.doFilter(ApiBasicAuthFilter.java:44)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:767)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.StatisticsHandler.handle(StatisticsHandler.java:53)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
2015-03-09 17:54:12,953 DEBUG 816231420@scm-web-41650:com.cloudera.api.ApiInvoker: API Error 405 [/api/v9/clusters/cluster%201/commands/stop]: null
2015-03-09 17:54:12,953 DEBUG 816231420@scm-web-41650:com.cloudera.api.ApiInvoker: API Error 405 [/api/v9/clusters/cluster%201/commands/stop]: null
2015-03-09 17:54:12,954 DEBUG 816231420@scm-web-41650:com.cloudera.api.LoggingOutInterceptor: API response:
---------- id: 89
Response code: 405
Content-Type: null
Headers:
Allow=[POST, GET, DELETE, PUT, OPTIONS, HEAD]
Date=[Mon, 09 Mar 2015 09:54:12 GMT]
Content-Length=[0]
2015-03-09 17:57:40,342 INFO 945123281@scm-web-41660:com.cloudera.server.web.cmf.AuthenticationSuccessEventListener: Authentication success for user: admin

 

 

 

 

/api/v9/clusters/cluster%201/commands/stop
 
2 ACCEPTED SOLUTIONS

avatar
Super Collaborator

Hello,

 

Thanks for the log snippet; from the reply, I see a couple of things that need comment.

 

A) It looks like you attempted to perform an HTTP GET method against that /stop endpoint. This expects an HTTP POST method, not GET. Retry with POST in order for this command to succeed. [1]

 

B) The endpoint you cite (/api/v9/cluster%201/commands/stop) is a high-level command to issue STOP to an entire named cluster. If you want to stop individual services, you must use /clusters/{clusterName}/services/{serviceName}/commands/stop and specify the exact service you wish to stop. [2]

 

Example using curl, to stop a MapReduce service (meaning ALL ROLES get stopped):

 

$ curl -X POST -u adminuser:password -v 'http://cluster.example.com:7180/api/v9/clusters/Cluster%201/services/MAPREDUCE-1/commands/stop'

 

 

Example using curl, to stop only a specific role (JobTracker) under a MapReduce service:

 

$ curl -X POST -u "adminuser:password" -i -v -H "content-type:application/json" -d '{"items" : ["mapreduce-JOBTRACKER-1234123412341234123412341234"] }' 'http://cluster.example.com:7180/api/v9/clusters/Cluster%201/services/MapReduce-1/roleCommands/stop'

 

 

[1] - http://cloudera.github.io/cm_api/apidocs/v9/path__clusters_-clusterName-_commands_stop.html

[2] - http://cloudera.github.io/cm_api/apidocs/v9/path__clusters_-clusterName-_services_-serviceName-_comm...

View solution in original post

avatar
Explorer

Hi

 

Thanks for your reply very help full.We are trying to gracefully shutdown the cluster when the UPS power is less than 20 % .

 

That is why we need the stop command badly .Would appreciate if you could give us the exact command 

 

Sorry we are new to this 

 

 

 

View solution in original post

2 REPLIES 2

avatar
Super Collaborator

Hello,

 

Thanks for the log snippet; from the reply, I see a couple of things that need comment.

 

A) It looks like you attempted to perform an HTTP GET method against that /stop endpoint. This expects an HTTP POST method, not GET. Retry with POST in order for this command to succeed. [1]

 

B) The endpoint you cite (/api/v9/cluster%201/commands/stop) is a high-level command to issue STOP to an entire named cluster. If you want to stop individual services, you must use /clusters/{clusterName}/services/{serviceName}/commands/stop and specify the exact service you wish to stop. [2]

 

Example using curl, to stop a MapReduce service (meaning ALL ROLES get stopped):

 

$ curl -X POST -u adminuser:password -v 'http://cluster.example.com:7180/api/v9/clusters/Cluster%201/services/MAPREDUCE-1/commands/stop'

 

 

Example using curl, to stop only a specific role (JobTracker) under a MapReduce service:

 

$ curl -X POST -u "adminuser:password" -i -v -H "content-type:application/json" -d '{"items" : ["mapreduce-JOBTRACKER-1234123412341234123412341234"] }' 'http://cluster.example.com:7180/api/v9/clusters/Cluster%201/services/MapReduce-1/roleCommands/stop'

 

 

[1] - http://cloudera.github.io/cm_api/apidocs/v9/path__clusters_-clusterName-_commands_stop.html

[2] - http://cloudera.github.io/cm_api/apidocs/v9/path__clusters_-clusterName-_services_-serviceName-_comm...

avatar
Explorer

Hi

 

Thanks for your reply very help full.We are trying to gracefully shutdown the cluster when the UPS power is less than 20 % .

 

That is why we need the stop command badly .Would appreciate if you could give us the exact command 

 

Sorry we are new to this