Get service status

@param service   name of the service to be checked
@param cluster   URI of the cluster
@return String   normalized service status
@throws Exception exception     *
541206
public String retrieveServiceStatus(String service, String cluster) throws Exception {
        String status = "";
        String endPoint = "/service/deploy-api/deploy/status/service?service=" + service;
        String element = "$.status";
        Future response;

        this.setRestProtocol("https://");
        this.setRestHost(cluster);
        this.setRestPort(":443");

        response = this.generateRequest("GET", true, null, null, endPoint, null, "json");
        this.setResponse("GET", (Response) response.get());
        assertThat(this.getResponse().getStatusCode()).as("It hasn't been possible to obtain status for service: " + service).isEqualTo(200);

        String json = this.getResponse().getResponse();

        String value = this.getJSONPathString(json, element, null);

        switch (value) {
            case "0":
                status = "deploying";
                break;
            case "1":
                status = "suspended";
                break;
            case "2":
                status = "running";
                break;
            case "3":
                status = "delayed";
                break;
            default:
                throw new Exception("Unknown service status code");
        }

        return status;
    }
115411
def get_clusters():
        
        LOGGER.debug("ClusterService.get_clusters")
        params = SessionService.complete_transactional_req(None)
        if MappingService.driver_type != DriverFactory.DRIVER_REST:
            if params is None:
                params = {}
            params['OPERATION'] = 'getClusters'
            args = {'properties': params}
        else:
            if params is None:
                args = {'http_operation': 'GET', 'operation_path': ''}
            else:
                args = {'http_operation': 'GET', 'operation_path': '', 'parameters': params}

        response = ClusterService.requester.call(args)

        if MappingService.driver_type != DriverFactory.DRIVER_REST:
            response = response.get()

        ret = None
        if response.rc == 0:
            ret = []
            for datacenter in response.response_content['clusters']:
                ret.append(Cluster.json_2_cluster(datacenter))
        elif response.rc != 404:
            err_msg = 'ClusterService.get_clusters - Problem while getting clusters. ' \
                      'Reason: ' + str(response.response_content) + ' - ' + str(response.error_message) + \
                      " (" + str(response.rc) + ")"
            LOGGER.warning(err_msg)
            if response.rc == 500 and ArianeMappingOverloadError.ERROR_MSG in response.error_message:
                raise ArianeMappingOverloadError("ClusterService.get_clusters", ArianeMappingOverloadError.ERROR_MSG)
            # traceback.print_stack()
        return ret
1344021
def get_all_services(resource_root, cluster_name="default", view=None):
  
  return call(resource_root.get,
      SERVICES_PATH % (cluster_name,),
      ApiService, True, params=view and dict(view=view) or None)
792307
@Override
    public void checkIn(ServiceHandle<S> handle) throws Exception {
        checkNotNull(handle);

        S service = handle.getService();
        ServiceEndPoint endPoint = handle.getEndPoint();

        // Figure out if we should check this revision in.  If it was created before the last known invalid revision
        // for this particular end point, or the cache is closed, then we shouldn't check it in.
        Long invalidRevision = _invalidRevisions.get(endPoint);
        Long serviceRevision = _checkedOutRevisions.remove(handle);

        if (_isClosed || (invalidRevision != null && serviceRevision < invalidRevision)) {
            _pool.invalidateObject(endPoint, service);
        } else {
            _pool.returnObject(endPoint, service);
        }
    }
1264729
def check_service(self):
        """"""
        try:
            service = yield Service.get(self.service_id)
        except couch.NotFound:
            raise exceptions.ValidationError('Service {} not found'
                                             .format(self.service_id))

        if service.service_type != 'repository':
            raise exceptions.ValidationError('{} is not a repository service'
                                             .format(self.service_id))

        if service.state != State.approved:
            raise exceptions.ValidationError('{} is not an approved service'
                                             .format(self.service_id))
137614
@When("^All resources from service '(.+?)' have been freed$")
    public void checkResources(String service) throws Exception {
        Future<Response> response = commonspec.generateRequest("GET", true, null, null, "/mesos/state-summary", null, null);

        String json = "[" + response.get().getResponseBody() + "]";
        String parsedElement = "$..frameworks[?(@.active==false)].name";
        String value = commonspec.getJSONPathString(json, parsedElement, null);

        Assertions.assertThat(value).as("Inactive services").doesNotContain(service);
    }
107488
public static clusterinstance get(nitro_service service, Long clid) throws Exception{
		clusterinstance obj = new clusterinstance();
		obj.set_clid(clid);
		clusterinstance response = (clusterinstance) obj.get_resource(service);
		return response;
	}
851351
public final ServiceStatusType getServiceStatus(){
    	//Initial value for status just in case "true" of "false" is not found
		ServiceStatusType serviceStatus = ServiceStatusType.UNKNOWN;
    	if ("true".equals(status)){
    		serviceStatus = ServiceStatusType.RUNNING;
    	} else if ("false".equals(status)){
    		serviceStatus = ServiceStatusType.STOPPED;
    	}		    	
    	return serviceStatus;
	}
965403
def status(name, sig=None):
    '''
    
    '''
    cmd = 's6-svstat {0}'.format(_service_path(name))
    out = __salt__['cmd.run_stdout'](cmd)
    try:
        pid = re.search(r'up \(pid (\d+)\)', out).group(1)
    except AttributeError:
        pid = ''
    return pid
300272
def get(self, url, instance, service_check_tags, run_check=False):
        ""
        self.log.debug('Fetching CouchDB stats at url: %s' % url)

        auth = None
        if 'user' in instance and 'password' in instance:
            auth = (instance['user'], instance['password'])

        # Override Accept request header so that failures are not redirected to the Futon web-ui
        request_headers = headers(self.agentConfig)
        request_headers['Accept'] = 'text/json'

        try:
            r = requests.get(
                url, auth=auth, headers=request_headers, timeout=int(instance.get('timeout', self.TIMEOUT))
            )
            r.raise_for_status()
            if run_check:
                self.service_check(
                    self.SERVICE_CHECK_NAME,
                    AgentCheck.OK,
                    tags=service_check_tags,
                    message='Connection to %s was successful' % url,
                )
        except requests.exceptions.Timeout as e:
            self.service_check(
                self.SERVICE_CHECK_NAME,
                AgentCheck.CRITICAL,
                tags=service_check_tags,
                message="Request timeout: {0}, {1}".format(url, e),
            )
            raise
        except requests.exceptions.HTTPError as e:
            self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL, tags=service_check_tags, message=str(e))
            raise
        except Exception as e:
            self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL, tags=service_check_tags, message=str(e))
            raise
        return r.json()
512959
@Override
    public String getConnectionInfo() throws Exception {
        return String.format("Cluster Name - %s : Keyspace Name - %s : CF Name - %s ::: ReadCL - %s : WriteCL - %s ", ClusterName, KeyspaceName, TableName, ReadConsistencyLevel, WriteConsistencyLevel);
    }
376033
public <T> T getService(String serviceName) {
    T service = findService(serviceName, true);
    if (service == null) {
      throw new IllegalArgumentException(format("No service found named \"%s\"", serviceName));
    }

    return service;
  }
668349
public static activity_status[] get(nitro_service client) throws Exception
	{
		activity_status resource = new activity_status();
		resource.validate("get");
		return (activity_status[]) resource.get_resources(client);
	}
723779
def service_status(self, name):
        

        return self._loop.run_coroutine(self._client.service_status(name))
1148888
@Override
  public OperationStatus getOperationStatus(OperationHandle opHandle) throws HiveSQLException {
    try {
      TGetOperationStatusReq req = new TGetOperationStatusReq(opHandle.toTOperationHandle());
      TGetOperationStatusResp resp = cliService.GetOperationStatus(req);
      // Checks the status of the RPC call, throws an exception in case of error
      checkStatus(resp.getStatus());
      OperationState opState = OperationState.getOperationState(resp.getOperationState());
      HiveSQLException opException = null;
      if (opState == OperationState.ERROR) {
        opException = new HiveSQLException(resp.getErrorMessage(), resp.getSqlState(), resp.getErrorCode());
      }
      return new OperationStatus(opState, opException);
    } catch (HiveSQLException e) {
      throw e;
    } catch (Exception e) {
      throw new HiveSQLException(e);
    }
  }
1066403
public String getAdminStatus() throws AtlasServiceException {
        String result = AtlasBaseClient.UNKNOWN_STATUS;
        WebResource resource = getResource(service, STATUS.getPath());
        JSONObject response = callAPIWithResource(STATUS, resource, null, JSONObject.class);
        try {
            result = response.getString("Status");
        } catch (JSONException e) {
            LOG.error("Exception while parsing admin status response. Returned response {}", response.toString(), e);
        }
        return result;
    }
782600
public static qos_stats get(nitro_service service) throws Exception{
		qos_stats obj = new qos_stats();
		qos_stats[] response = (qos_stats[])obj.stat_resources(service);
		return response[0];
	}